Justin Collins wrote:
> hakunin wrote:
>> The parenthesis have been discussed before, but maybe this is another
>> angle. In a nutshell:
>>
>> print(true and true) # => throws the following:
>>
>> SyntaxError: compile error
>> (irb):14: syntax error, unexpected kAND, expecting ')'
>> print(true and true)
>>               ^
>>     from (irb):14
>>
>> print (true and true) # => works. (notice the space)
>>
>> It looks obvious that the only parenthesis around the method args are
>> containing the expression to be evaluated, so why would this cause
>> ambiguity?  Especially strange that the incorrect way - with the space
>> - works as expected.  Is there any fix in the works? Anything done
>> about this?
>>
>> Thanks!
>>
>>   
> 
> print (true and true) is not incorrect, it is just using parentheses for 
> a different purpose.
> 
> What you are seeing is just a precedence issue, because "and" and "or" 
> have very low precedence.
> 
> Compare:
> 
> print(true && true)
> print(true or true)
> print(true || true)
> print((true and true))
> print((true or true))
> 
> Maybe you already knew that, though?
> 

This one really puzzles me. I know of the operator precedence
hierarchy in Ruby, but this doesn't seem to help me figure
out why the parser gets confused here. Could someone give
some insights in the thought process of the parser when it
encounters "print(true and true)" ?

Thanks,

Michael