Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created February 7, 2014 06:34
Show Gist options
  • Save yaotti/8858244 to your computer and use it in GitHub Desktop.
Save yaotti/8858244 to your computer and use it in GitHub Desktop.
Ruby's named params and a hash with string keys
def foo(arg: 1)
puts "arg: #{arg}"
end
foo({ arg: 10 })
#=> arg: 10
foo({ 'arg' => 10 })
#=> /Users/yaotti/sandbox/named-params.rb:1:in `foo': wrong number of arguments (1 for 0) (ArgumentError)
# from /Users/yaotti/sandbox/named-params.rb:6:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment