From: "Skye Shaw!@#$" Date: 2010-11-14T18:30:14+09:00 Subject: Re: Is it possible to break a loop from within an internal lambda function? On Nov 14, 1:18 am, "Skye Shaw!@#$" wrote: > On Nov 14, 12:54 am, timr wrote: > > > #I want to use: solve_by_iter { |test|  lambda{puts test; break}.call > > if (1..6).all?{|num| test%num == (num-1)} } > > What's wrong with returning a boolean value from the inner lambda and > breaking in the block? > > solve_by_iter { |test| break if lambda{puts test; false}.call } Though if you really, really -really, want to kill the call stack from an arbitrary depth you could try (gulp): def solve_by_iter counter = 1 catch :break do loop do yield counter counter += 1 end end end solve_by_iter { |test| lambda{p test;throw :break}.call }