Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active August 5, 2020 01:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save havenwood/11168412 to your computer and use it in GitHub Desktop.
Save havenwood/11168412 to your computer and use it in GitHub Desktop.
Fallthrough case statement in Ruby
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