Getopt/long and ARGV

Why does getopts delete the option arguments but not the options
themselves from ARGV:

$ cat opt.rb
require “getopt/long”
include Getopt
opts = Long.getopts(
["–plot", BOOLEAN],
["–foo", OPTIONAL]
)
p ARGV

$ ruby opt.rb --plot --foo 8
["–plot", “–foo”]

Wouldn’t it be better for #getopts to delete all members of ARGV that it
recognizes? Then you can use ARGF for the remaining file names.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs