Pretty big/breaking change in the new Ruby 2.0.0 patch level (p0 => p195).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}] |
nasty bug. But, tbh I would never write a hash that mixed old and new styles like that.
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
"Fixed" here:
https://bugs.ruby-lang.org/projects/ruby-200/repository/revisions/40381/diff
https://bugs.ruby-lang.org/issues/8260