Actions
Bug #11378
closedSyntax error when passing Array boolean logic into method
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.1p85 (2015-02-26 revision 49769) [i686-linux]
Description
Passing Array boolean logic into a method is yielding a syntax error when the opening parenthesis is not separated from the method name by a space. It works fine if there is a space or if the boolean logic is enclosed in parenthesis.
Here's my sample code:
def meth arr
puts arr
end
[17] pry(main)> meth([true,false,true] and [true,false,false]) # Produces error when parenthesis and method name dont have a space in between
SyntaxError: unexpected ')', expecting end-of-input
[17] pry(main)> meth(([true,false,true] and [true,false,false])) #Works fine
true
false
false
=> nil
[19] pry(main)> meth ([true,false,true] and [true,false,false]) # Works fine. Notice the space between method call and parenthesis
true
false
false
Updated by nobu (Nobuyoshi Nakada) almost 9 years ago
- Status changed from Open to Rejected
It's irrelevant to array, but a precedence problem.
An expression of and
keyword can't be an argument without parentheses.
Actions
Like0
Like0