page 241, option_2.rb
I was wondering why nothing happens with option -s
without additional parameter :
% ruby -w rubyworld/option_2.rb -s
"we are sorting by size"
The fact is that "-s", "--size
is overlapping -sSORT
. With -t instead of -s :
parser.on("-t SORT", "Sort Type") do |value|
now it raises an error, as expected :
% ruby -w rubyworld/option_2.rb -t
rubyworld/option_2.rb:31:in `<main>': missing argument: -t (OptionParser::MissingArgument)