Project

General

Profile

Actions

Bug #5571

closed

Syntax Error when put String eql? with logical operation ("||") or "("&&")

Added by rongyj (Yongjun Rong) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0dev (2011-11-04 trunk 33634) [x86_64-darwin10.8.0]
Backport:
[ruby-core:40742]

Description

There has a syntax error when try to connect two string eqls? with the logical operation ("||") and ("&&") as below
{code}
ruby-head :001 > test="test"
=> "test"
ruby-head :002 > puts test.eql?("test") || test.eql?("test1")
true
=> nil
ruby-head :003 > puts test.eql?"test" || test.eql?"test1"
SyntaxError: (irb):3: syntax error, unexpected tSTRING_BEG, expecting $end
puts test.eql?"test" || test.eql?"test1"
^
from /usr/local/rvm/rubies/ruby-head/bin/irb:16:in <main>' ruby-head :004 > puts (test.eql?("test") || test.eql?("test1")) true => nil ruby-head :005 > puts (test.eql?"test" || test.eql?"test1") SyntaxError: (irb):5: syntax error, unexpected tSTRING_BEG, expecting ')' puts (test.eql?"test" || test.eql?"test1") ^ (irb):5: syntax error, unexpected ')', expecting $end from /usr/local/rvm/rubies/ruby-head/bin/irb:16:in '
ruby-head :006 >
{code}

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0