As someone who doesn't know Ruby, I would like to point out that this program is an excellent demonstration of why Ruby's non-standard syntax is awful, confusing and hard to learn!
Ruby's syntax for defining a function is apparently:
fizz_buzz = ->(number) do
... stuff ...
end
This is very confusing if you've used C where -> is a binary operator. I understand what it does, but only because I've used Coffeescript. And the "do" keyword in most languages is used to signal loops, apparently "do...end" is a block delimiter in Ruby instead.
Having functions be defined with expressions is confusing.
The string mess on the next line is an awful feature that makes languages such as shell, Perl and PHP bug-prone -- and no exception here. Apparently double quoting in Ruby means next to nothing, because it seems like a damn-near Turing complete language which has magic meaning inside quotes. The double quotes, pound sign, braces, and question marks have meanings here that are rather non-obvious.
Ruby's syntax for defining a function is apparently:
This is very confusing if you've used C where -> is a binary operator. I understand what it does, but only because I've used Coffeescript. And the "do" keyword in most languages is used to signal loops, apparently "do...end" is a block delimiter in Ruby instead.Having functions be defined with expressions is confusing.
The string mess on the next line is an awful feature that makes languages such as shell, Perl and PHP bug-prone -- and no exception here. Apparently double quoting in Ruby means next to nothing, because it seems like a damn-near Turing complete language which has magic meaning inside quotes. The double quotes, pound sign, braces, and question marks have meanings here that are rather non-obvious.