On 20.10.2006 15:45, 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?

The direct form works.

irb(main):008:0> 10.times {|i| p i; break if i > 5}
0
1
2
3
4
5
6
=> nil

Hm, at the moment I do not have an idea.  What do you need that for? 
Maybe there is a different solution.  For example:

irb(main):009:0> crit = lambda {|i| i > 5}
=> #<Proc:0x00395698@(irb):9>
irb(main):010:0> 10.times {|i| p i; break if crit[i]}
0
1
2
3
4
5
6
=> nil

Cheers

	robert