Last active
August 5, 2020 01:45
-
-
Save havenwood/11168412 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment