From: "David A. Black" Date: 2009-10-11T19:38:50+09:00 Subject: Tip du jour: no need to chomp before to_i Hi -- Very minor point, but in case it's useful: n = gets.chomp.to_i does the same thing as: n = gets.to_i because to_i doesn't do anything with the trailing newline anyway. This is even the case if you use the fussier Integer method. Integer is fussier in the sense that it doesn't like non-numeric strings: "123abc".to_i => 123 Integer("123abc") => error But it doesn't mind whitespace: Integer("\t \n 123\n ") => 123 so you can do Integer(gets) without chomping. I can't think of any exceptions or weird edge cases, but if you can, please report them :-) David -- The Ruby training with D. Black, G. Brown, J.McAnally Compleat Jan 22-23, 2010, Tampa, FL Rubyist http://www.thecompleatrubyist.com David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)