-
-
Save 3014zhangshuo/6311c6553ba76d2afec0a35d1f3d7ae7 to your computer and use it in GitHub Desktop.
Fallthrough case statement in Ruby
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
| value = :initial | |
| catch :redo do | |
| case value | |
| when :initial | |
| puts 'initial' | |
| value = :changed | |
| redo | |
| when :changed | |
| puts 'changed' | |
| value = :omgwtfbbq | |
| redo | |
| else | |
| puts 'got here' | |
| end | |
| end | |
| # >> initial | |
| # >> changed | |
| # >> got here | |
| # => nil |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not a good way.