From: Nasir Khan Date: 2007-04-17T14:17:33+09:00 Subject: Re: Why the 'next' call within the Proc obj created by 'lambda' always returns nil on ruby 1.8.6? ------=_Part_56222_33046854.1176787051003 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I would like to see any comments to this question too. irb(main):001:0> pr = Proc.new {next 99} => # irb(main):002:0> pr.call => 99 irb(main):003:0> irb(main):004:0* pr = lambda {next 99} => # irb(main):005:0> pr.call => nil Does seem counter to what is written in the PickAxe, "next" in case of Proc created by Kernel.lambda does *not* return the value passed to it, though it does exit the block. - Nasir On 4/16/07, FindSun wrote: > > Hi, guys, > > I am one of the chinese translators for "Programming Ruby 2nd". And > one reader in China reported that the 'next' call within the Proc obj > created by 'lambda' always returns nil, instead of the specified > value. > > E.g., (the code snippets is from page 358) > > pr = lambda {next 99} > puts pr.call > > While, for the Proc obj created by Proc#new, it works fine. > > Could you please have a look, why 1.8.5/6 changed to that way? Or it's > just a bug? > > Regards, > > -- > FindSun > > ------=_Part_56222_33046854.1176787051003--