------art_37904_17477989.1180192366824
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 5/26/07, Henrik Schmidt <no.spam / nspmaxyz.abc> wrote:
>
> 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  2
>      puts foo            # 42
>      puts self.foo       # "foo"
>      puts foo()          # "foo"
>    end
>
>    def foo
>      "foo"
>    end
>
> end
>
> Foo.new.output




C++ does the same thing, you know. It's not mysterious if you understand how
the language's scoping rules work.

------art_37904_17477989.1180192366824--