Skip to content

Instantly share code, notes, and snippets.

@masassiez
Created January 26, 2012 02:00
Show Gist options
  • Save masassiez/1680449 to your computer and use it in GitHub Desktop.
Save masassiez/1680449 to your computer and use it in GitHub Desktop.
rescue FizzBuzz
def fizzbuzz(limit)
e ||= 0
( e += 1 ) > limit ? return : raise
rescue lambda { |_| e%15==0 }
puts "FizzBuzz"; retry
rescue lambda { |_| e%5==0 }
puts "Buzz"; retry
rescue lambda { |_| e%3==0 }
puts "Fizz"; retry
rescue lambda { |_| e }
puts e; retry
end
fizzbuzz(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment