From: 7stud -- Date: 2007-11-04T05:20:56+09:00 Subject: Re: dragons and factorials (keyboard input) Thufir wrote: > I googled, didn't find the answer, posted, googled more, found the > answer: > > number = gets.chomp.to_i > ------------------------------------------------------------ String#to_i str.to_i(base=10) => integer ------------------------------------------------------------------------ Returns the result of interpreting ***leading characters*** in _str_ as an integer... .Extraneous characters past the end of a valid number are ****ignored***. If there is not a valid number at the start of _str_, +0+ is returned. This method never raises an exception. ----------------------------------------------------------- String#chomp str.chomp(separator=$/) => new_str ------------------------------------------------------------------------ Returns a new +String+ with the given record separator removed from the end of _str_ (if present).... "hello".chomp #=> "hello" "hello\n".chomp #=> "hello" "hello\r\n".chomp #=> "hello" "hello\n\r".chomp #=> "hello\n" "hello\r".chomp #=> "hello" "hello \n there".chomp #=> "hello \n there" "hello".chomp("llo") #=> "he" Based on those descriptions will the result returned by input.chomp().to_i be any different than the result returned by: input.to_i ?? -- Posted via http://www.ruby-forum.com/.