From: Mike Gold Date: 2009-01-12T08:05:05+09:00 Subject: Re: functional programming Mike Gold wrote: > > By the way, since locals are determined at parse time, I don't see any > particular reason why this cannot work: > > bisect = lambda { |x, y| (x + y)/2.0 } > # ... > bisect(5, 6) > > Whether or not that _should_ work is a different story. The pro is > that I can swap lambdas and methods without changing syntax. The con > is, at least, that the meaning of existing code could change (when a > bisect method already exists). I see this is a bad idea due to the cases where the lambda is not a local variable. [lambda { |x, y| (x + y)/2.0 }].first(5, 6) Since the rule couldn't apply here, the special-case exception for a local lambda would be silly. -- Posted via http://www.ruby-forum.com/.