From: Robert Klemme Date: 2003-07-21T21:21:03+09:00 Subject: Re: Usage Message for GetoptLong "Joey Gibson" schrieb im Newsbeitrag news:n2aghvsr96i7ob0v7f8gc6ekgkmigl5cm1@4ax.com... > On Sat, 19 Jul 2003 01:05:06 +0900, "Robert Klemme" > wrote: > > ||| def hasDescription?(optarray) > ||| case optarray[-1] > ||| when GetoptLong::REQUIRED_ARGUMENT, > ||| GetoptLong::NO_ARGUMENT, > ||| GetoptLong::OPTIONAL_ARGUMENT > > Why not just key off of the length of the array? If you get a three element > array then you don't have a description; four elements means description. That does not work since the array length is not fixed: There can be arbitrary many option strings before the argument setting. One could of course simplify the test to test the last element's type (String means description, Fixnum means argument setting): def has_description?(optarray) String === optarray[-1] end > don't like keying off those constants because more could be added, Yes, that's a disadvantage. > and > since they are just numbers anyway, you _might_ get a false > positive/negative based on the description. Probably not, I guess... Ah > well. TMTOWTDI, I suppose. Err, what? > Can we get one or the other of these approaches added to the code base to > make this a standard part of GetoptLong? Matz, what do you think? I support that. Regards robert