Quoting xrfang / hotmail.com, on Sun, Mar 20, 2005 at 02:44:56PM +0900:
> Hi All,
> 
> Recently I found a slightly annoying behavior in Ruby -- local variable
> scoping:  Example of code:
> 
> Javascript version:
> 
> var aNumber = 3
> function doSomething()
> {
>    var anotherNumber = aNumber *2
> }
> 
> Translate to Ruby:
> 
> aNumber = 3
> def doSomething
>     anotherNumber = aNumber * 2
> end

aNumber goes somewhere in the meta-class of Object, I think.

Here's a useful idiom:

  @aNumber=3
      ==>3
  def doSomething; @aNumber*2; end
      ==>nil
  doSomething
      ==>6

You could redo your example appending "@" before evaling the variable, I suspect.

Sam