From: Farrel Lifson Date: 2006-10-22T06:22:39+09:00 Subject: Re: break from block On 21/10/06, matt neuburg wrote: > Farrel Lifson wrote: > > > I've just run into the following problem. Doing this: > > block = lambda{|i| i > 5 ? break : nil} > > n.times &block > > raises a LocalJumpError, I assume because break is not valid from > > within a Proc object. Is there any way to get around this? > > block = lambda{|i| p i; i > 5 ? throw(:done) : nil} > catch(:done) {42.times &block} > > m. > > -- > matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ > Tiger - http://www.takecontrolbooks.com/tiger-customizing.html > AppleScript - http://www.amazon.com/gp/product/0596102119 > Read TidBITS! It's free and smart. http://www.tidbits.com I've tried using throw/catch but it's a serious performance cost. Farrel