3 ms·
Ruby uses a nil type, but due to its flexibility, nil can also respond to messages! Its presence is greatly appreciated, and it's not a NULL in the "This is a p
by cheald 16y ago
Ruby uses a nil type, but due to its flexibility, nil can also respond to messages! Its presence is greatly appreciated, and it's not a NULL in the "This is a pointer to 0x0" sense, but in terms of how you use it, it's functionally equivalent.
By means of example:
irb(main):003:0> nil.class
=> NilClass
irb(main):004:0> nil.nil?
=> true
irb(main):005:0> nil.methods
=> ["inspect", "method", "tap", "&", "clone", "public_methods", "__send__", ...]
irb(main):006:0> nil.is_a? String
=> false