What does "(...) interpreted as grouped expression" mean?

Jasper Kennis picture Jasper Kennis · Jun 25, 2015 · Viewed 9.4k times · Source

I'm using a Ruby linter in Atom and for some lines it gives the following warning:

(...) interpreted as grouped expression

An example of a line that get's this warning is this:

elsif not (params[:vacancy].nil? or params[:vacancy]['company_id'].nil? or params[:vacancy]['company_id'] == "0" )

How should that line be improved to make the warning go away?

Answer

Jörg W Mittag picture Jörg W Mittag · Jun 25, 2015

The warning is

(...) interpreted as grouped expression

And it means exactly what it says: in Ruby, parentheses can be used for three purposes, expression grouping, parameter lists and argument lists. This warning is emitted when Ruby thinks that you want an argument list but wrote a grouped expression instead. The most common cause is whitespace between the name of the message and the argument list in a message send like this:

foo.bar (1, 2)

This will be interpreted not as an argument list for the message send, but rather a grouped expression, which, in this particular case, is a SyntaxError.

In your particular case, the warning seems to be a false positive.