On Thu, 26 Jun 2008, 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
>
> At least this happens on my buddy's win XP box that I am using, to
> play with Ruby.

Are you testing this on irb or by writing on a file and running through 
ruby? When I test this on irb, both x and y are defined as methods. While 
running through ruby, both are nil.

Aditya