Created
April 19, 2019 02:04
-
-
Save koduki/c319f93e5fd40d8d8bd4d67e11bc89dc to your computer and use it in GitHub Desktop.
FizzBuzz with Pattern Match
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
(1..100).map do |i| | |
case [i % 3, i % 5] | |
in [0, 0] | |
"FizzBuzz" | |
in [0, _] | |
"Fiz" | |
in [_, 0] | |
"Buzz" | |
else | |
i.to_s | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment