# Syntax error, unexpected kOR

**URL:** <https://www.ruby-forum.com/t/syntax-error-unexpected-kor/90178>\
**Category:** Ruby\
**Created:** [March 26, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected-kor/90178 "2007-03-26T16:56:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nonno\_lele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nonno\_lele](https://www.ruby-forum.com/u/nonno_lele)\
**Post date:** [March 26, 2007, 4:56pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected-kor/90178/1 "2007-03-26T16:56:21Z")

</div>

Hello there,

I’m newbie with ruby and to be onest I’m quite surprised about a  
strange behaviour I found:

How the interpreter works with this lines looks odd to me:

def dummy?  
(true or false )  
end

This one has no problem… and also this one:

def dummy?  
(true or  
false )  
end

But what happen when you split the boolean condition into 2 different  
lines and u put the OR in the 2nd line??

def dummy?()  
(true  
or false )  
end

U get _"syntax error, unexpected kOR, expecting ‘)’ "_

I agree that the interpreter is not able to undestand this one:

def dummy?()  
true  
or false  
end

because of the missing () and return… but using the ( ) it should  
work.

At least using Return and ( ) should work…

def dummy?()  
return (true  
or false )  
end

But it is not.

Where is my fault? Looks strange to me that an high level language  
forces you to think about in which position you’ve to put the OR.

Is there a way to force the interpreter to evaluate the block inside  
the () before anything else?

Thanks in advance ,

Regards,

Em.

PS: ive found an old discussion about the same error but I’m not sure  
this answer my question:  
[http://tinyurl.com/2852ns](http://tinyurl.com/2852ns)

PS2: using || instead of OR gives the same result.

cheers.

---

<div class="post-metadata">

**Author:** ![nonno\_lele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nonno\_lele](https://www.ruby-forum.com/u/nonno_lele)\
**Post date:** [March 26, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected-kor/90178/2 "2007-03-26T17:06:24Z")

</div>

On Mar 26, 4:52 pm, “nonno\_lele” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m newbie with ruby and to be onest I’m quite surprised about a  
> strange behaviour I found: […]
> 
> def dummy?()  
> (true  
> or false )  
> end

Currently, it is the same as (true; or false).

This works:

puts((puts ‘foo’; puts ‘bar’; ‘qux’))

# \>\> foo

# \>\> bar

# \>\> qux

And so does this:

puts((  
puts ‘foo’  
puts ‘bar’  
‘qux’))

# \>\> foo

# \>\> bar

# \>\> qux

Kind regards,  
Florian G.

---

<div class="post-metadata">

**Author:** ![nonno\_lele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nonno\_lele](https://www.ruby-forum.com/u/nonno_lele)\
**Post date:** [March 26, 2007, 5:07pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected-kor/90178/3 "2007-03-26T17:07:24Z")

</div>

On 3/26/07, nonno\_lele [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> def dummy?()  
> or false  
> end
> 
> But it is not.

> Where is my fault? Looks strange to me that an high level language  
> forces you to think about in which position you’ve to put the OR.

The problem is that interpreter needs to know somehow that the line  
should continue.  
Putting ‘or’ or ‘||’ at the end of the line tells it that. Other way  
is to use \ as the last character on the line.

> PS: ive found an old discussion about the same error but I’m not sure  
> this answer my question:  
> [http://tinyurl.com/2852ns](http://tinyurl.com/2852ns)

this is another problem.

---

<div class="post-metadata">

**Author:** ![nonno\_lele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nonno\_lele](https://www.ruby-forum.com/u/nonno_lele)\
**Post date:** [March 26, 2007, 5:47pm UTC](https://www.ruby-forum.com/t/syntax-error-unexpected-kor/90178/4 "2007-03-26T17:47:39Z")

</div>

On 26 Mar, 17:05, “Jano S.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 3/26/07, nonno\_lele [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

CUT

> > forces you to think about in which position you’ve to put the OR.
> 
> The problem is that interpreter needs to know somehow that the line  
> should continue.  
> Putting ‘or’ or ‘||’ at the end of the line tells it that. Other way  
> is to use \ as the last character on the line.

Err… in a ideal world the interpreter should understand it cause it  
finds and open “(” without the closure…

obviusly IMHO 🙂

thank you for the answer.

Cheers,

Em.
