furufuru
5/5/2006 11:52:00 PM
Thank you all who responded!
Tim Hunter wrote:
> Try Float()
>
> irb(main):001:0> Float("1.3")
> => 1.3
> irb(main):002:0> Float("hello")
> ArgumentError: invalid value for Float(): "hello"
> from (irb):2:in `Float'
> from (irb):2
Ah, is this a change introduced in Ruby 1.8 ?
In fact, I knew Float, but the old pickaxe book says
Float Float( arg ) -> aFloat
Returns arg converted to a float. Numeric types are converted
directly, nil is converted to 0.0, and the rest are converted
using arg.to_f.
Anyway, my problem is solved.
Cheers,
Ryo