Hi,

In message "[ruby-talk:14226] || .. or Question"
    on 01/04/25, Jim Freeze <jim / freeze.org> writes:

|Why do I get the following output

|-Case1
|s = (n == 3 or n == 5)
|=> false

|-Case2
|puts (n == 3 or n == 5)
|=> if:2: parse error
|if:2: parse error

|-Case3
|puts (n == 3 || n == 5)
|=> false


Because they are different.  Parenthesises in case1 are for expression
grouping, whereas those in case2 and case3 are for method arguments (a
left parenthesis just after an identifier denotes beginning of method
argument list).

The former can only contain single expression/statement.  The latter
can contain list of expressions, not statements.

So "puts ((n == 3 or n == 5))" will be OK.

For the same reason, "puts (1+2),5" is parsed as "(puts(1+2)),5", thus
causes syntax error.

							matz.