From: James Edward Gray II Date: 2005-12-22T13:20:04+09:00 Subject: Re: String > Integer Conversion Problem On Dec 21, 2005, at 6:13 PM, Jacob Fugal wrote: > On 12/21/05, Timothy Hunter wrote: >> The Integer() method raises ArgumentError if given an empty, >> non-numeric, or otherwise non-well-formed string. > > On 12/21/05, James Edward Gray II wrote: >> if ARGV.all? { |n| n =~ /\A\d+\Z/ } >> puts "Usage..." >> exit >> else >> one, two = ARGV.map { |n| Integer(n) } >> end > > So could we rewrite this as: > > begin > one, two = ARGV.map{ |n| Integer(n) } > rescue ArgumentError > puts Usage > exit > end Yeah, that's better. Neither of our versions checks the number of arguments though and we probably should... James Edward Gray II