From: Rolf Timmermans Date: 2011-01-17T21:39:15+09:00 Subject: Re: Obscure syntax error On Jan 17, 2011, at 12:19 , Alex Gutteridge wrote: > I think Rolf's point is that in *both* of those last two cases there is no method called x - the only difference being that in the first case he tries to pass a string to the non-existent method in the second a symbol. So why is the first (correctly) throwing a NoMethodError and the second gives a *syntax* error? Exactly. And to be entirely clear, the fact that the method does not exist doesn't even matter. If the method does exist, the same syntax error is raised if the first argument is a symbol. And when using parentheses, no syntax error occurs... Compare: def x(*args); end x :y # No error def x(*args); end x = nil x "y" # No error def x(*args); end x = nil x :y # foo.rb:3: syntax error, unexpected ':', expecting $end def x(*args); end x = nil x(:y) # No error def x(*args); end x = nil x :y, "z" # foo.rb:3: syntax error, unexpected ':', expecting $end def x(*args); end x = nil x "y", :z # No error Kind regards, Rolf Timmermans