Ruby automatically expands Hash into keyword arguments without double splat -


the below ruby code results in: unknown keyword: (argumenterror):

def test(x={}, y: true); end  test({a:1}) 

why? expect happen test(**{a:1}), don't understand why hash being automagically expanded without double splat.

since x optional, hash moves on kwarg argument. unspecified keywords raise error in case:

def foo(name:)   p name end  foo # raises "argumenterror: missing keyword: name" expected foo({name: 'joe', age: 10}) # raises "argumenterror: unknown keyword: age" 

check out this article


Comments

Popular posts from this blog

android - questions about switching from C2DM to GCM -

c++ - Qt setGeometry: Unable to set geometry -

batch file - How to extract all multi-volume RAR archives from subfolders of a folder? -