Project

General

Profile

Actions

Bug #11236

closed

inconsistent behavior using ** vs hash as method parameter

Added by akostadinov (Aleksandar Kostadinov) almost 9 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
[ruby-core:69494]

Description

Using ruby 2.2.2 I see this work:

[18] pry(main)> def test(cmd, opts={})
[18] pry(main)*   puts cmd,opts
[18] pry(main)* end  
=> :test
[19] pry(main)> test(:ads, :d => 6, :f => :gah, {a:3,b:4} => 3)
ads
{:d=>6, :f=>:gah, {:a=>3, :b=>4}=>3}
=> nil

But this fails:

[2] pry(main)> def test(cmd, **opts)
[2] pry(main)*   puts cmd, opts
[2] pry(main)* end  
[9] pry(main)> test(:ads, :d => 6, :f => :gah, {a:3,b:4} => 3)
ArgumentError: wrong number of arguments (2 for 1)
from (pry):2:in `test'

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14183: "Real" keyword argumentClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0