Default values

suggest change

With OptionParser, set defaults by pre-populating the hash that stores the options:

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

When you define the parser, it overwrites the default if the user provides 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