From: William James Date: 2007-09-10T10:25:08+09:00 Subject: Re: Bug in lambda? On Sep 9, 3:28 am, dbl...@wobblini.net wrote: > Hi -- > > On Sun, 9 Sep 2007, kevin cline wrote: > > This looks like a pretty serious bug. It seems that lambda- > > expressions are not properly localizing their formal arguments: > > > bash-3.2$ ruby --version > > ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] > > > bash-3.2$ cat lambda-bug.rb > > a = 0 > > f = lambda { |a| a } > > puts "a = #{a}" > > puts "f.call(1) => #{f.call(1)}" > > puts "now a = #{a}" > > > bash-3.2$ ruby lambda-bug.rb > > a = 0 > > f.call(1) => 1 > > now a = 1 > > Definitely not a bug. Block parameters use assignment semantics, with > regard to the scope in which the block appears. In your example, > you're assigning 1 to a. If you create a local variable inside the > block, however, it only exists for the duration of the block. > > As far as remember, Guy Decoux and I are the only two people who think > that this makes perfect sense Does this mean that you and Guy and Matz smoked the same wacky tobaccy?