Nice article, thanks for sharing! Quick suggestion:
You can get to pattern matching power in this place:
defp get_fizz_buzz_value(num) do cond do rem(num, 15) == 0 -> "FizzBuzz" rem(num, 3) == 0 -> "Fizz" rem(num, 5) == 0 -> "Buzz" true -> to_string(num) end end
->
defp get_fizz_buzz_value(num) when rem(num, 15) == 0, do: "FizzBuzz" defp get_fizz_buzz_value(num) when rem(num, 3) == 0, do: "Fizz" defp get_fizz_buzz_value(num) when rem(num, 5) == 0, do: "Buzz" defp get_fizz_buzz_value(num), do: to_string(num)
Might be even nicer to skip rem(,15) in favor of rem(,3) and 5 together separately, but it will also affect the Ruby code then
I like this... a lot!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice article, thanks for sharing! Quick suggestion:
You can get to pattern matching power in this place:
->
Might be even nicer to skip rem(,15) in favor of rem(,3) and 5 together separately, but it will also affect the Ruby code then
I like this... a lot!