syntax error, unexpected ',', expecting ')'

41,837

The extra space is the culprit. Use:

do_something(arg0, arg1)
Share:
41,837
dt1000
Author by

dt1000

Updated on July 18, 2022

Comments

  • dt1000
    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
      Dave Newton over 12 years
      Or not using a space before the parens, long-recommended to avoid.
    • sepp2k
      sepp2k over 12 years
      To 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
    kinduff over 11 years
    Same 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
    Paweł Obrok over 11 years
    Use 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
    kinduff over 11 years
    But is a large project, and the weird thing is that some days behind it worked like a charm, but now I can't.
  • sadaf
    sadaf about 10 years
    I dont understand this? when ruby is space insensitive then why is do_something(arg0, arg1) different from do_something (arg0, arg1)