1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rubyのnilってなんじゃ

Posted at

なんか怖かったのでメモ。

>> nil.class
=> NilClass
>> nil.class.superclass
=> Object
>> nil.class.superclass.superclass
=> BasicObject
>> nil.class.superclass.superclass.superclass
=> nil
>> nil.class.superclass.superclass.superclass.superclass
NoMethodError: undefined method `superclass' for nil:NilClass
        from (irb):11
        from /usr/local/rvm/rubies/ruby-2.2.1/bin/irb:11:in `<main>'

この入れ子構造はもちろん、

>> nil.class.superclass.superclass.superclass.class
=> NilClass
>> nil.class.superclass.superclass.superclass.class.superclass
=> Object
>> nil.class.superclass.superclass.superclass.class.superclass.superclass
=> BasicObject
>> nil.class.superclass.superclass.superclass.class.superclass.superclass.class
=> Class

となる。

1
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?