Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created October 27, 2012 23:53
Show Gist options
  • Save havenwood/3966916 to your computer and use it in GitHub Desktop.
Save havenwood/3966916 to your computer and use it in GitHub Desktop.
Named Params Ruby 2.0.0
def why(noun: 'Ruby', adjective: 'exquisite') # parens required or SyntaxError
"#{noun} is #{adjective}."
end
why
#=> "Ruby is exquisite."
why adjective: 'tasty'
#=> "Ruby is tasty."
why adjective: 'tasty', noun: 'Bacon'
#=> "Bacon is tasty."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment