Skip to content

Instantly share code, notes, and snippets.

@johana-star
Created March 25, 2012 08:53
Show Gist options
  • Save johana-star/2192466 to your computer and use it in GitHub Desktop.
Save johana-star/2192466 to your computer and use it in GitHub Desktop.
FizzBuzz in Ruby (revised
(0..100).each do |number|
case
when number % 3 == 0 then puts "Fizz" + ("Buzz" if number % 5 == 0).to_s
when number % 5 == 0 then puts "Buzz"
else puts number
end
end
@johana-star
Copy link
Author

Seems clever, but this complication is not as readable, slower, and more likely to break with editing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment