diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-07-07 10:49:53 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-07-07 13:49:47 -0700 |
commit | 3fcffceafd2bce7186851bf4899484c545a9ace8 (patch) | |
tree | 06b41623a8db9f1bc5cf45e997ff99acbb7809e8 /lib/optparse.rb | |
parent | c1ebb384fdc222b58398d89a877a06b7efd5e290 (diff) | |
download | ruby-3fcffceafd2bce7186851bf4899484c545a9ace8.tar.gz |
Fix default argument values for OptParse::Switch#summarize
The documentation describes these arguments being hashes, and the method
is called with hashes, so a hash default makes more sense.
The method would fail previously if called without arguments and @short
or @long contained a non-integer value.
Fixes [Bug #10928]
Diffstat (limited to 'lib/optparse.rb')
-rw-r--r-- | lib/optparse.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb index 9937e2500d..25e262a69a 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -592,7 +592,7 @@ class OptionParser # +max+ columns. # +indent+:: Prefix string indents all summarized lines. # - def summarize(sdone = [], ldone = [], width = 1, max = width - 1, indent = "") + def summarize(sdone = {}, ldone = {}, width = 1, max = width - 1, indent = "") sopts, lopts = [], [], nil @short.each {|s| sdone.fetch(s) {sopts << s}; sdone[s] = true} if @short @long.each {|s| ldone.fetch(s) {lopts << s}; ldone[s] = true} if @long |