Last active
December 16, 2015 06:39
-
-
Save chikoski/5392733 to your computer and use it in GitHub Desktop.
Ruby 2.0 のキーワード引数を使った例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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