syntax error, unexpected ',', expecting ')'
41,837
The extra space is the culprit. Use:
do_something(arg0, arg1)
Author by
dt1000
Updated on July 18, 2022Comments
-
dt1000 almost 2 years
I just installed Ruby 1.9.2 after having used 1.8.7, as there is a feature I need. I had called many of my methods like this:
do_something (arg0, arg1)
With 1.9.2, i get the following error,
syntax error, unexpected ',', expecting ')'
and the fix seems to be:do_something arg0, arg1
But this could take me hours to fix all the cases. Is there a way around this? Why is it an error in the first place? thanks
-
Dave Newton over 12 yearsOr not using a space before the parens, long-recommended to avoid.
-
sepp2k over 12 yearsTo be fair: Your code does produce warnings that you shouldn't put spaces before open parentheses using ruby 1.8.7. So it's not like this problem suddenly appeared out of nowhere without warning.
-
-
kinduff over 11 yearsSame problem here, now installing 1.8.7 to see if it works. My "syntax error" is:
/home/kinduff/www/creamcheese/app/admin/grupos.rb:9: syntax error, unexpected ':', expecting '}' a { href: admin_recipe_path(receta.id) }, do
-
Paweł Obrok over 11 yearsUse explicit () and don't use a comma before the block, like so:
a({href: admin_recipe_path(receta.id)}) do
. The way you do it ruby thinks the {} denote a block when in fact it's a hash. -
kinduff over 11 yearsBut is a large project, and the weird thing is that some days behind it worked like a charm, but now I can't.
-
sadaf about 10 yearsI dont understand this? when ruby is space insensitive then why is do_something(arg0, arg1) different from do_something (arg0, arg1)