/test/non_local_return.rb

http://github.com/feyeleanor/RubyGoLightly · Ruby · 18 lines · 13 code · 2 blank · 3 comment · 0 complexity · 03bcbbaf92d073b6eb590d6e6f34ae32 MD5 · raw file

  1. def yielder
  2. yield
  3. end
  4. def non_local_return
  5. yielder do
  6. puts "ok"
  7. return 1
  8. puts "nop"
  9. end
  10. puts "should not get here"
  11. end
  12. puts non_local_return
  13. puts "end"
  14. # => ok
  15. # => 1
  16. # => end