15

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

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
dt1000
  • 3,684
  • 6
  • 43
  • 65
  • 4
    Or not using a space before the parens, long-recommended to avoid. – Dave Newton Dec 17 '11 at 00:36
  • 8
    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. – sepp2k Dec 17 '11 at 00:41

1 Answers1

43

The extra space is the culprit. Use:

do_something(arg0, arg1)
Paweł Obrok
  • 22,568
  • 8
  • 74
  • 70
  • 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` – kinduff Nov 27 '12 at 22:58
  • 1
    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. – Paweł Obrok Nov 28 '12 at 17:11
  • But is a large project, and the weird thing is that some days behind it worked like a charm, but now I can't. – kinduff Nov 28 '12 at 17:35
  • I dont understand this? when ruby is space insensitive then why is do_something(arg0, arg1) different from do_something (arg0, arg1) – sadaf May 04 '14 at 06:25