Skip to content

Instantly share code, notes, and snippets.

@topher6345
Last active August 29, 2015 14:04
Show Gist options
  • Save topher6345/4544804ec7794304409e to your computer and use it in GitHub Desktop.
Save topher6345/4544804ec7794304409e to your computer and use it in GitHub Desktop.
Everyone loves FizzBuzz
# functional but linter hates it
(1..100).map {|e| (e % 15).zero? ? "FizzBuzz": (e % 3).zero? ? "Fizz" : (e % 5).zero? ? "Buzz": e }.each {|e| puts e }
# linted
(1..100).map do |elem|
puts 'FizzBuzz' if (elem % 15).zero?
puts 'Fizz' if (elem % 3).zero?
puts 'Buzz' if (elem % 5).zero?
puts elem
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment