[ruby-core:70062] [Ruby trunk - Bug #11378] [Rejected] Syntax error when passing Array boolean logic into method

From: nobu@...
Date: 2015-07-21 10:04:31 UTC
List: ruby-core #70062
Issue #11378 has been updated by Nobuyoshi Nakada.

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.


----------------------------------------
Bug #11378: Syntax error when passing Array boolean logic into method
https://bugs.ruby-lang.org/issues/11378#change-53480

* Author: Sameer Deshmukh
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [i686-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
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

~~~



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next