Skip to content

Instantly share code, notes, and snippets.

@chikoski
Last active December 16, 2015 06:39
Show Gist options
  • Save chikoski/5392733 to your computer and use it in GitHub Desktop.
Save chikoski/5392733 to your computer and use it in GitHub Desktop.
Ruby 2.0 のキーワード引数を使った例
def fizzbuzz(from:1, to:100)
(from..to).to_a.map{|i|
msg = "#{i}: "
if(i % 3 == 0)
msg += "Fizz"
end
if(i % 5 == 0)
msg += "Buzz"
end
msg
}
end
puts (fizzbuzz to: (ARGV.shift || 100).to_i).join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment