Skip to content

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

instance method

GetoptLong#each

each() { |option_name, option_argument| ... }

Iterator version of ‘get’.

The block is called repeatedly with two arguments: The first is the option name. The second is the argument which followed it (if any). Example: (‘–opt’, ‘value’)

The option name is always converted to the first (preferred) name given in the original options to GetoptLong.new.

See also .new #each_option #error_message also in 3.3 · 3.2 · 3.1