Joel VanderWerf wrote:
> 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? Does anyone feel this is an important feature to have?
> 
> It is possible in 1.8, using the next keyword:
> 
> def test
>    puts 'before'
>    yield 2
>    puts 'after'
> end
> 
> test do |i|
>    next if i > 1
>    puts "a lot of code"
> end

This is great! I never thought of using 'next'.

Thank you!
-- 
Posted via http://www.ruby-forum.com/.