On 07/03/12 07:15, Robert Klemme wrote:
> You do not want the class but rather the kind of "foo".  "local
> variable" is not a class.  You can do
>
> irb(main):032:0>  class Bogey<  Dance
> irb(main):033:1>  def bar
> irb(main):034:2>  a=0
> irb(main):035:2>  printf "foo ->  %p\n", defined?(foo)
> irb(main):036:2>  printf "a ->  %p\n", defined?(a)
> irb(main):037:2>  printf "none ->  %p\n", defined?(none)
> irb(main):038:2>  end
> irb(main):039:1>  end
> =>  nil
> irb(main):040:0>  Bogey.new.bar
> foo ->  "method"
> a ->  "local-variable"
> none ->  nil
> =>  nil
Great answer. I'm pretty new to Ruby and assumed that defined? returned 
a boolean. That'll learn me for not reading the manual.

Sam