Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

OptionParser#getopts

getopts(*args)

Wrapper method for getopts.rb.

Example
params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option")
# params["a"] = true   # -a
# params["b"] = "1"    # -b1
# params["foo"] = "1"  # --foo
# params["bar"] = "x"  # --bar x
# params["zot"] = "z"  # --zot Z
See also .getopts #environment #help #def_tail_option also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0