RosettaCodeData/Task/Null-object/Ruby/null-object.rb

11 lines
303 B
Ruby
Raw Permalink Normal View History

2015-02-20 00:35:01 -05:00
puts "@object is nil" if @object.nil? # instance variable
puts "$object is nil" if $object.nil? # global variable, too
# It recognizes as the local variable even if it isn't executed.
object = 1 if false
puts "object is nil" if object.nil?
2015-11-18 06:14:39 +00:00
# nil itself is an object:
puts nil.class # => NilClass