From: Timothy Hunter Date: 2005-12-23T06:32:50+09:00 Subject: Re: String > Integer Conversion Problem Matthew Feadler wrote: > First, thanks all very much for the lively discussion thus far. It's > proven very useful. > > Timothy Hunter wrote: > >>The Integer() method raises ArgumentError if given an empty, >>non-numeric, or otherwise non-well-formed string. > > > Hmm...apparently not--at least not w/ 1.8.2 on mswin32. > > This: > > begin > one, two = ARGV.map{ |n| Integer(n) } > rescue ArgumentError > puts "Usage..." > exit > end > > puts one > puts two > > Outputs: > > nil > nil > > When fed no command-line arguments. It does work as intended if any of > the args are non-empty strings, however. That would be because Integer is never called. If there are no command-line arguments, ARGV is empty, there's nothing to map.