From: Dave Thomas Date: 2001-11-09T03:27:04+09:00 Subject: [ruby-talk:24674] Re: Is their a more succinct way to do this? Jim Freeze writes: > Hi: > > I have a program that takes several parameters from the command line. > I need to test these parameters that: > 1) they exist > 2) they are not nil > 3) they are not empty > > So, in my code I have > if !defined?(param) || param.nil? || param.empty? > # err > end How about something like err(...) unless ARGV[0] && !ARGV[0].empty? There's no need to test for defined?, as the array will return nil for missing elements. For personal scripts, I tend to use file_name = ARGV.shift or raise("Missing file name") target = ARGV.shift or raise("Missing target") For stuff that's more general, I sometimes define def usage $stderr.puts "