From: Joel VanderWerf Date: 2008-05-21T12:26:20+09:00 Subject: Re: Is there any good source for the logic behind some of the methods? Michael W. Ryder wrote: > I am trying to figure out why methods that seem to do the same thing > behave so differently. For example Integer("0377") returns 255 as > expected for an octal number but "0377".to_i returns 377. Or why > Integer("12e3") crashes while Float("12e3") returns 12000.0 as expected. > I was hoping to find somewhere that tells when to use one or the other > method depending upon expected inputs. It is very time consuming to > have to keep testing a method to find out it's limitations. Guessing: "0377".to_i returns 377 -- because #to_i has an default argument base=10, so in this case you have implicitly told #to_i to use decimal. Integer("0377") returns 255 -- because there's no base specified, so it has to be determined from the string itself. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407