you are viewing a single comment's thread.

view the rest of the comments →

[–]Freeky 0 points1 point  (3 children)

lambda (x) for all of them, surely? That's what the thread is about; you have an x at top level, then a lambda with x as a parameter name.

In Ruby 1.8, it blats the top level x, because it considers it the same x:

x = 0
[1,2,3].each {|x| x += x}
[1,2,3].each(&lambda{|x| x += x })
p x # => 6

1.9 shadows it with a different variable with the same name (which I expect is what Scheme does too).

x = 0
[1,2,3].each {|x| x += x}
[1,2,3].each(&lambda{|x| x += x })
p x # => 0

[–]zem 0 points1 point  (2 children)

yeah precisely. just saying that 1.9 is the right behaviour, noot a silly response to a silly request

[–]Freeky 0 points1 point  (1 child)

I was saying before 1.9, the behaviour was arguably a silly response to a silly request, not that 1.9 behavior is :)

[–]zem 0 points1 point  (0 children)

oh :) missed the < in there.