From: Ross Bamford Date: 2006-04-14T23:29:59+09:00 Subject: Re: Strange Integer() behavior On Fri, 2006-04-14 at 22:54 +0900, Robert Dober wrote: > On 4/14/06, Robert Klemme wrote: > > > > 2006/4/14, Patrick Joyce : > > > I guess the project for tomorow is to figure out where that "039" is > > > coming from in the Mechanize parser. > > > > Well, if you want to use Integer then the obvious fix is to do str.sub/^0+/, '' > > > > Ruby can do better > Integer("08") or Integer("038") bomb > "08".to_i + "038".to_i => 46 > It's often a bit too relaxed, though: "oh eight".to_i + "038".to_i # => 38 Whereas: Integer("oh eight") + Integer("038".sub(/^0+/, '')) ArgumentError: invalid value for Integer: "oh eight" from (irb):4:in `Integer' from (irb):4 -- Ross Bamford - rosco@roscopeco.REMOVE.co.uk