Skip to content

Instantly share code, notes, and snippets.

@blairanderson
Created December 27, 2012 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save blairanderson/4386477 to your computer and use it in GitHub Desktop.
Save blairanderson/4386477 to your computer and use it in GitHub Desktop.
(1..100).each do |each|
if each % 3 == 0 and each % 5 == 0
puts "FizzBuzz"
elsif each % 3 == 0
puts "Fizz"
elsif each % 5 == 0
puts "Buzz"
else
puts each
end
end
@kytrinyx
Copy link

The variable name each kind of suggests the wrong thing. It's like saying:

people.all do |all|
  if all.age > 50
    puts "damn, you're old!"
  else
    puts "ok, go ahead"
  end
end

By naming the variable all I'm making it sound like we're checking all the ages every time.

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