Project

General

Profile

Actions

Bug #12323

closed

Wrong example code in OptionParser documentation

Added by SerSamgy (Semyon Gaivoronskiy) almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
[ruby-core:75224]

Description

There is a complete example code in OptionParser documentation (http://ruby-doc.org/stdlib-2.3.0/libdoc/optparse/rdoc/OptionParser.html). Trying to run it got next error message:
example.rb:33:in 'parse': undefined local variable or method 'option_parser' for OptparseExample:Class (NameError) from example.rb:138:in '<main>'

I fixed a code of that example and attached it to this ticket. Maybe it should be moderated.


Files

example.rb (4.08 KB) example.rb Option of example code SerSamgy (Semyon Gaivoronskiy), 04/27/2016 05:01 PM

Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Bug #12899: OptParse documentation : example is brokenClosedActions

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED

Thank you.

I think that OptparseExample.parse should be an instance method but not a class method.

Actions #2

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Status changed from Open to Closed

Applied in changeset r54808.


optparse.rb: [DOC] fix example code [ci skip]

  • lib/optparse.rb: [DOC] fix example code. base on the code by
    Semyon Gaivoronskiy in [ruby-core:75224]. [Bug #12323]

Updated by nagachika (Tomoyuki Chikanaga) almost 8 years ago

  • Backport changed from 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE

ruby_2_3 r54924 merged revision(s) 54808.

Actions #4

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Has duplicate Bug #12899: OptParse documentation : example is broken added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0