From: kjana@...4lab.to (YANAGAWA Kazuhisa) Date: 2002-08-04T12:20:12+09:00 Subject: Re: String -> Integer anomoly? In message <021901c23b52$c7d86580$0300a8c0@austin.rr.com> hal9000@hypermetrics.com writes: > > Why does "09".to_i return 9 > > and Integer("09") raise an error? (snip) > "09".to_i # 9 (assumes decimal with leading 0) > "0xabc".to_i # 0 And then Integer() considers "09" as a representation of an octal number, but it contains "9", exceeding radix of octal. Integer("12") #=> 12 in decimal Integer("012") #=> 10 in decimal Integer("0x12") #=> 18 in decimal Integer() raises exception on ill-formed string passed for its argument, where ill-formed means whole expression doesn't satisfy conditions for integer literals. > ruby -e 'p 012' #=> 10 > ruby -e 'p 09' #=> -e:1: Illegal octal digit # Hmm, Integer() should show more descriptive message like on syntax # checking? -- kjana@dm4lab.to August 4, 2002 What is done can't be undone.