trans. (T. Onoma) wrote:
> Is that right?
> 
> irb(main):001:0> i = 1.0/0
> => Infinity
> irb(main):002:0> -i.to_s
> NoMethodError: undefined method `-@' for "Infinity":String
>         from (irb):2
> 
> Doesn't do this for other numbers.
> 
> irb(main):004:0> -4.0.to_s
> => "-4.0"

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 ".".

- Jamis

-- 
Jamis Buck
jgb3 / email.byu.edu
http://www.jamisbuck.org/jamis