Created
April 1, 2016 13:44
-
-
Save anonymous/6a1e4a2b85028de36b2a03dadf8b1793 to your computer and use it in GitHub Desktop.
if :symbols are immutable how can you use :symbols with default values and then change?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@options = {:user => "john", | |
:password => nil, | |
:host => nil, | |
:warn => 100, | |
:crit => 500} | |
opt = OptionParser.new | |
opt.on("--user USER", "Connect as user") do |f| | |
@options[:user] = f | |
end | |
opt.on("--password PASSWORD", "Connection password") do |f| | |
@options[:password] = f | |
end | |
opt.on("--host HOST", "Host to connect to") do |f| | |
if @options[:host] | |
@options[:host] << f | |
else | |
@options[:host] = [f] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment