[ruby-talk:02463] Precedence question

From: Clemens Hintze <c.hintze@...>
Date: 2000-04-12 06:33:29 UTC
List: ruby-talk #2463
Dave Thomas writes:

...

>      6 * inc 7

...

>      -:6: parse error
> 
> Is it correct to say that it's simply a precedence thing, and that
> it's being parsed as
> 
>    (6*inc) 7
> 
> or is there something more subtle going on?

Hmm ... from the grammar I believe that Ruby parses

   inc 7

as a statement not as a expression! Statements, however, are only
allowed within expressions if they occur in parentheses. That means

   6 * (inc 7)

is okay! So it is not a precedence problem, although it looks like
one. :-)

> Thanks
> 
> Dave

-- 
Clemens Hintze  mailto: c.hintze@gmx.net

In This Thread