From: Matthew Feadler Date: 2005-12-23T07:35:43+09:00 Subject: Re: String > Integer Conversion Problem Timothy Hunter wrote: > That would be because Integer is never called. If there are no > command-line arguments, ARGV is empty, there's nothing to map. That makes perfect sense. Thanks. So, after some experimentation I've got the code listed below. It successfully checks for: 1.) an empty ARGV (i.e., no command-line args) 2.) more than 2 arguments 3.) non-numeric arguments 4.) negative arguments 5.) first arg greater than second arg Which is to say, it does everything I want it to. However, I wonder if it can be optimized, condensed? Here be code: $usage = "Usage" def print_usage val if val=="exit" print $usage exit else print $usage end end if ARGV!=[] and !(ARGV.length > 2) begin arg0, arg1 = ARGV.map{ |n| Integer(n) } if (arg0 < 0) or (arg1 < 0) print_usage("exit") elsif arg0>arg1 print_usage("exit") end rescue ArgumentError print_usage("exit") end else print_usage("exit") end -- Posted via http://www.ruby-forum.com/.