From: Sean O'Halpin Date: 2008-06-29T20:40:32+09:00 Subject: Re: question about defined? and y On Thu, Jun 26, 2008 at 6:48 PM, Ruby Freak wrote: > The defined? keyword seems to have some funky behaviors. > I have decided that the best way to use it is to compare the output to > nil as it returns a myriad of results that all result in truth. > > puts (defined?(x) == nil ? "Not defined" : "Is defined") > > but... > What's up with y? > > The uninitialized variable y returns from defined? as "method" rather > than "nil" ???? > > puts defined?(x) # => nil > > puts defined?(y) # => method > $ ruby -e "puts defined?(y); require 'yaml'; puts defined?(y)" nil method Regards, Sean