Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
OptionParser#parse
(*::String argv, ?into: ::OptionParser::_Intoable) -> ::Array[::String]
(::Array[::String] argv, ?into: ::OptionParser::_Intoable) -> ::Array[::String]
parse(*argv, **keywords)
lib/optparse.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/optparse.rb, line 1865
def parse(*argv, **keywords)
argv = argv[0].dup if argv.size == 1 and Array === argv[0]
parse!(argv, **keywords)
end
Parses command line arguments argv in order when environment variable POSIXLY_CORRECT is set, and in permutation mode otherwise. When optional into keyword argument is provided, the parsed option values are stored there via []= method (so it can be Hash, or OpenStruct, or other similar object).