Skip to content

Instantly share code, notes, and snippets.

@taisyo7333
Created January 24, 2016 10:30
Show Gist options
  • Save taisyo7333/43728fca816bdcbfa545 to your computer and use it in GitHub Desktop.
Save taisyo7333/43728fca816bdcbfa545 to your computer and use it in GitHub Desktop.
Ruby throw - catch
# encoding: utf-8
def bar
catch(:calc) do
throw :calc , 100
end
end
p bar
# => 100
e>ruby Code3-166.rb
ruby Code3-166.rb
100
@taisyo7333
Copy link
Author

throw に渡した第2引数 100 (値)をcatchの戻り値とできる。
どうやら値に限るらしい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment