From: Bertram Scharpf Date: 2009-06-05T21:46:22+09:00 Subject: Re: Question about exiting from a block Hi, Am Freitag, 05. Jun 2009, 06:48:43 +0900 schrieb Joel VanderWerf: > Guoliang Cao wrote: >> I have code above and wonder if it is possible to use >> return/break/anything to stop execution of block and return control to >> test() to execute code after yield. I know it is impossible in 1.8. How >> about 1.9? > > It is possible in 1.8, using the next keyword: Slightly modified: def f ; puts "A" ; puts yield ; puts "Z" ; "F" ; end f { next "X" ; puts "Y" } #=> "F" puts "-" f { break "X" ; puts "Y" } #=> "X" The output is: A X Z - A Will this work in 1.9, too? Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de