Last active
October 5, 2016 08:52
-
-
Save kodaitakahashi/dfb88c304c53baa776dc98d2ee613a35 to your computer and use it in GitHub Desktop.
catch throwを使った時の大域脱出
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catch (:escape) do | |
loop do | |
puts 'loop1' | |
loop do | |
puts 'loop2' | |
throw (:escape, 'escape loop1 & loop2) | |
end | |
end | |
end | |
# => loop1 | |
# => loop2 | |
# => escape loop1 & loop2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment