Created
July 7, 2013 13:25
-
-
Save kouba-c/5943456 to your computer and use it in GitHub Desktop.
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
class MyException < Exception; end | |
class FizzBuzz < MyException; end | |
class Fizz < MyException; end | |
class Buzz < MyException; end | |
i = 1 | |
j = 100 | |
begin | |
raise FizzBuzz if i%3 == 0 && i%5 == 0 | |
raise Fizz if i%3 == 0 | |
raise Buzz if i%5 == 0 | |
raise | |
rescue Exception => exp | |
puts exp.kind_of?(MyException) ? exp : i | |
i += 1 | |
retry if i <= j | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment