Skip to content

Instantly share code, notes, and snippets.

@stephencelis
Created May 16, 2013 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephencelis/5595842 to your computer and use it in GitHub Desktop.
Save stephencelis/5595842 to your computer and use it in GitHub Desktop.
Pretty big/breaking change in the new Ruby 2.0.0 patch level (p0 => p195).
def keyword_fun arg = nil, **options
[arg, options]
end
keyword_fun hello: 'world', 'goodnight' => 'moon'
# Ruby 2.0.0p0
# => [nil, {:hello=>"world", "goodnight"=>"moon"}]
# Ruby 2.0.0p195
# => [{"goodnight"=>"moon"}, {:hello=>"world"}]
@stephencelis
Copy link
Author

Yeah, it's just more surprising than anything else. You can no longer pass a HashWithIndifferentAccess as keyword arguments, or use **options to extract the last hash from *args (you have to use Array#pop or Array#extract_options!, as before).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment