Created
May 17, 2009 23:35
-
-
Save adamsanderson/113223 to your computer and use it in GitHub Desktop.
This does not do what I expected at all.
This file contains 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
# 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