Skip to content

Instantly share code, notes, and snippets.

@snuxoll
Created March 15, 2009 16:39
Show Gist options
  • Save snuxoll/79472 to your computer and use it in GitHub Desktop.
Save snuxoll/79472 to your computer and use it in GitHub Desktop.
# adds two named arguments passed in, named :first and
# :second respectively
def add(args)
args[:first] + args[:second]
end
# Call it using 1.8 and below style
puts add(:first => 2, :second => 4) # 6
# Call it using the 1.9 style hash syntax
puts add(first: 2, second: 4) # 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment