Trans wrote:
> It really has nothing to do with eval, your just setting a local
> variable.
> 
> An unfortuate side effect of the setter notation is that it conflicts
> with local var setting. Local var setting wins out, so you have to use
> self as the reciever in order to tell ruby you mean the setter method.
> 
> T.

Since you bring this up, there are a few more cases where implicit locals 
declaration causes unexpected behavior (if new to ruby that is):

x = 10
(1..10).each { |i| x = x + i }  # x == 65
x = 10
(1..10).each { |i| x = i }  # x == 10

So if you're assigning x to itself in some way, it recognizes x in the 
enclosing scope, else it creates a new local.  That's kind of a confusing rule. 
    Also, what if I wanted the first example to create a local?  How do I refer 
to the toplevel `x` in the second?

I'd really like to see explicit locals declarations in Ruby, and this would all 
be solved by simply introducing `var` or `local`, as in `var x = 10`.  Even if 
it was only optional, and invoked with -strict-locals, I think many people 
would be happy.  Maybe I'll download the source and hack away to test it :)


Mike