How to 'return' from a Proc?

Kero van Gelder wrote:

I am trying to do

method() {

break if condition_met

}

to break out of the proc and thus finish the yield() in method()

But I can’t find the proper control word for it.
break is illegal, so is return.

Break works for me.

[kentda@v052a ruby]$ cat x.rb
def x
yield 1
yield 2
yield 3
end
x{|i|
print i,“…”
break if i == 2
print i,“\n”
}
print “done”
[kentda@v052a ruby]$ /usr/local/bin/ruby -v
ruby 1.8.0 (2003-06-23) [i686-linux]
[kentda@v052a ruby]$ /usr/local/bin/ruby x.rb
1…1
2…done

Could you divulge more information as to how it fails in your case?
See http://www.rubycentral.com/book/tut_expressions.html#UL
for more details.

···


([ Kent Dahl ]/)_ ~ [ http://www.pvv.org/~kentda/ ]/~
))_student_/(( _d L b_/ (pre-) Master of Science in Technology )
( __õ|õ// ) )Industrial economics and technological management(
_
/ö____/ (_engineering.discipline=Computer::Technology)