Quoting gvim (gvimrc@gmail.com):
Then I don't get this one:
var = 2
def f(x)
x = x + 1
return x
endputs f(var) #=> 3
puts var #=> 2
The line
x = x + 1
creates a new object. You can see this by printing the object id of x
before and after the sum:
...
def f(x)
puts("before: #{x.object_id}")
x = x + 1
puts("after: #{x.object_id}")
return x
end
...
gives here:
before: 5
after: 7
Carlo
···
Subject: Re: Passing script input as method args always global?
Date: mer 13 nov 13 11:18:48 +0000
--
* Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
* di parlare tanto di amore e di rettitudine? (Chuang-Tzu)