From: "Berger, Daniel" Date: 2007-03-22T03:09:38+09:00 Subject: Re: [ ruby-Bugs-8384 ] Discrepancy between GetoptLong.new and documentation > -----Original Message----- > From: noreply@rubyforge.org [mailto:noreply@rubyforge.org] > Sent: Wednesday, March 21, 2007 12:02 PM > To: ruby-core@ruby-lang.org > Subject: [ ruby-Bugs-8384 ] Discrepancy between > GetoptLong.new and documentation > > > Bugs item #8384, was opened at 2007-02-02 10:06 > You can respond by visiting: > http://rubyforge.org/tracker/?func=detail&atid=1698&aid=8384&g > roup_id=426 > > Category: Standard Library > Group: 1.8.5 > Status: Open > Resolution: None > Priority: 3 > Submitted By: Roel Harbers (rharbers) > Assigned to: Nobody (None) > Summary: Discrepancy between GetoptLong.new and documentation > > Initial Comment: > According to the documentation for getoptlong.rb, the > GetoptLong.new method requires an array of arrays to be passed: > > # The options to support are passed to new() as an array of arrays. > # Each sub-array contains any number of String option names > which carry > # the same meaning, and one of the following flags: > > However, this code fails: > require 'getoptlong' > options = GetoptLong.new( > [ > ['-a', GetoptLong::NO_ARGUMENT], > ['-b', GetoptLong::NO_ARGUMENT], > ] > ) > > This works: > require 'getoptlong' > options = GetoptLong.new( > ['-a', GetoptLong::NO_ARGUMENT], > ['-b', GetoptLong::NO_ARGUMENT] > ) > > Either the documentation could be fixed, or the call could > accept an array of arrays. Personally, I prefer the latter, > since it allows something like this: > > options = GetoptLong.new( > [ > ['-a', GetoptLong::NO_ARGUMENT], > ['-b', GetoptLong::NO_ARGUMENT], > # ['--debug', GetoptLong::NO_ARGUMENT], > ] > ) > > which the other form does not allow without removing the > comma from the -b line too. > > I made a patch againt 1.8.5 that lets set_options (and by > extension initialize) accept both forms. > > What do you people think? > > ---------------------------------------------------------------------- > > >Comment By: Roel Harbers (rharbers) > Date: 2007-03-21 19:01 > > Message: > Anyone? class? Bueller? Wait - people actually use that module? :-P But seriously, I think either way is fine - i.e. fix the docs, or allow the explicitly nested arrays. Regards, Dan This communication is the property of Qwest and may contain confidential or privileged information. Unauthorized use of this communication is strictly prohibited and may be unlawful. If you have received this communication in error, please immediately notify the sender by reply e-mail and destroy all copies of the communication and any attachments.