From: Farrel Lifson Date: 2006-10-21T07:47:15+09:00 Subject: Re: break from block On 20/10/06, Robert Klemme wrote: > On 20.10.2006 16:37, Farrel Lifson wrote: > > I'm just trying to optimise some code and I was wondering if doing > > block = lambda{|i| #processing; if i > 5; break} > > n.times &block > > would be any faster than doing it directly. > > I do not know a single case where the lambda variant is faster than the > direct block variant. AFAIK that's because of the conversion that > occurs. The advantage of the lambda variant is rather that you can > store the block away and reuse it multiple times. > > Regards > > robert From my informal benchmarking there's a very slight constant speedup of about 1s for my program. Farrel