Comment on Ruby mistakesparentComments−Xylakant13yIt's a special parser case. The reason is that defined? may be followed by an uninitialized constant: jruby-1.6.8 :089 > defined? Foo::Bar => nil jruby-1.6.8 :090 > Foo::Bar NameError: uninitialized constant Foo::Bar You don't want the argument to be evaluated because that could raise a NameError. It's actually an operator.−nirvdrum13yThanks for the clarification. I was recently surprised by the return value when:z = x.yz == x.y # => truedefined?(z) == defined?(x.y) # => false
Comments
It's a special parser case. The reason is that defined? may be followed by an uninitialized constant:
You don't want the argument to be evaluated because that could raise a NameError. It's actually an operator.Thanks for the clarification. I was recently surprised by the return value when:
z = x.y
z == x.y # => true
defined?(z) == defined?(x.y) # => false