T. Onoma
10/11/2004 4:11:00 AM
On Sunday 10 October 2004 11:28 pm, Jamis Buck wrote:
| No, but if you do:
|
| a = 4.0
| -a.to_s
|
| You get the same error. When parsing numeric constants, the Ruby parser
| includes '-' as part of the number. When '-' precedes a variable, it
| uses the "-@" operator, which has a lower precendence than ".".
Thanks, Jamis
I see. I'm a little surprised that's intended. I understand the precedence of
"." being before the "!" operator, but I would think it would occur right
after "-" and "+" unary operators, user-defined or not. (Maybe "~" too.)
That's part of the niftiness of what I was offering Markus about his
user-defined operators. One could expect them to have a precedence corollary
to Ruby's built-in operators.
Thanks again,
T.