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

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -