Default values

suggest change

With OptionsParser, it’s really easy to set up default values. Just pre-populate the hash you store the options in:

options = {
  :directory => ENV['HOME']
}

When you define the parser, it will overwrite the default if a user provide a value:

OptionParser.new do |opts|
  opts.on("-d", "--directory HOME", "Directory to use") do |d|
    options[:directory] = d
  end
end

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents