Hi there,

I've been playing around with Ruby for a while, but there's still one 
particular feature of the language that doesn't make sense to me. If you 
write a class containing a method and a class with the same name, the 
interpreter will pick the variable over the method, unless you 
specifically tells it not to. For example,

class Foo

   def output
     puts foo            # "foo"
     foo = 42
     puts foo            # 42
     puts self.foo       # "foo"
     puts foo()          # "foo"
   end

   def foo
     "foo"
   end

end

Foo.new.output

As seen above, there are several ways of getting around this, but this 
is the question: Why is this behaviour useful? As I see it, it's bad 
practice to give a method and a local variable the same name. At least I 
can't think of an example where it would make sense. Why not simply 
disallow this or at least have the interpreter issue a warning?

Best regards,
   Henrik Schmidt