Skip to content

Instantly share code, notes, and snippets.

@robballou
Created October 19, 2009 18:59
Show Gist options
  • Save robballou/213627 to your computer and use it in GitHub Desktop.
Save robballou/213627 to your computer and use it in GitHub Desktop.
params = {
:font_size => 10
}
# 1
defaults = {
:font => "Times-Roman",
:font_size => 11,
:stroke => false
}
defaults.each do |key, value|
if not params.include? key
params[key] = value
end
end
# 2
defaults = {
:font => "Times-Roman",
:font_size => 11,
:stroke => false
}
params = defaults.merge params
# 3
params = {
:font => "Times-Roman",
:font_size => 11,
:stroke => false
}.merge params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment