----- Original Message ----- 
From: "Gavin Sinclair" <gsinclair / soyabean.com.au>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
Sent: Saturday, August 03, 2002 7:39 PM
Subject: String -> Integer anomoly?


> Why does "09".to_i return 9
> and Integer("09") raise an error?

Arguably a feature. My understanding is that
this was done on purpose. 

It sometimes gets me confused, though.

I believe that Integer is "smarter" than
String#to_i.

This came up when we were discussing the fact
that to_i doesn't raise exceptions.

  "abc".to_i    # 0

It also doesn't know different bases.

  "09".to_i     # 9 (assumes decimal with leading 0)
  "0xabc".to_i  # 0

Someone else can elaborate more.

Hal