The following command works:
download_file(“Hello”, “World”, “Rubyists”, 34)
The following command fails:
download_file (“Hello”, “World”, “Rubyists”, 34)
The only difference is the space before the “(”. Why is the presence or absence of this space so significant? This was never a problem for me in Python. (On the other hand, I quickly learned to NEVER use tabs to indent when programming in Python.)
Because this is Ruby not Python. My understanding of why this is so
(which may be wrong or at least incomplete) is because you do not need
the parentheses at all, so you could say
download_file "Hello", "World", "Rubyists", 34
so if you have a space and a "(" then the space starts the parameter
list and then along comes a "(" which may now have a different
meaning, dependant on context. So the best thing is just to remember
not to put a space after the method name if you are using parentheses.
the space + () creates a new closure and that closure causes an error
because you have a bunch of commas outside of context. Colin is
right, I just wanted to elaborate that it creates a new closure.