2 ms·
It'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
by Xylakant 14y ago
It'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.
- nirvdrum 14y agoThanks 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