Created
January 24, 2016 10:26
-
-
Save taisyo7333/0c37d62c4aaa4b9bc161 to your computer and use it in GitHub Desktop.
Ruby throw - catch
This file contains hidden or 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
# encoding: SJIS | |
def foo | |
throw :exit | |
end | |
catch(:exit) { | |
foo | |
p 1 # Do not call | |
} | |
p 2 | |
# => 2 |
This file contains hidden or 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
>ruby Code3-165.rb | |
ruby Code3-165.rb | |
2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment