Skip to content

Instantly share code, notes, and snippets.

@adamsanderson
Created May 17, 2009 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamsanderson/113223 to your computer and use it in GitHub Desktop.
Save adamsanderson/113223 to your computer and use it in GitHub Desktop.
This does not do what I expected at all.
# throw catch test
class Thingy
def loop
value = catch(:cake) do
(0..7).each do |i|
puts "Looking at #{i}"
throw(:cake, i) if i == 3
end
end
puts "Done, value is #{value}"
end
end
t = Thingy.new
t.loop
# Looking at 0
# Looking at 1
# Looking at 2
# Looking at 3
# Done, value is 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment