From: Patrick Doyle Date: 2008-09-20T02:06:45+09:00 Subject: That was unexpected -- strange scoping behavior Consider the following piece of code: #!/usr/bin/env ruby def wow(idx, donetest) until donetest.call(idx) puts idx idx = idx + 1 end #until end #def wow idx = 2 puts "before wow, idx = #{idx}\n" wow(3, lambda {|x| x > 5}) puts "after wow, idx = #{idx}\n" # Now, suppose I used a different dummy variable for the lambda function puts "before wow, idx = #{idx}\n" wow(3, lambda {|idx| idx > 5}) puts "after wow, idx = #{idx}\n" --------------------------- When I just happened to use the name "idx" for my dummy variable in my lambda function, I was quite surprised to learn that it changed the value of "idx" in the enclosing scope. I suppose that makes sense (given Ruby's scoping rules), but it sure was unexpected! --wpd