Project

General

Profile

Actions

Bug #8507

closed

Keyword splat does not convert arg to Hash

Added by stephencelis (Stephen Celis) almost 11 years ago. Updated over 4 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]
Backport:
[ruby-core:55391]

Description

A single splat is useful to convert an object to an array as it passes from one method to the next, so I expected the double-splat to do the same and convert the object to a hash.

def splat *args
  p args
end
def double_splat **kwargs
  p args
end
splat(*nil)  # []
splat(**nil) # TypeError: no implicit conversion of nil into Hash

For the sake of consistency, wouldn't it make sense to wrap the double-splatted arg with Hash() the same way a single-splatted arg is wrapped with Array()?


Files

to-hash-kwarg.patch (939 Bytes) to-hash-kwarg.patch stephencelis (Stephen Celis), 06/10/2013 03:27 AM

Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Bug #9291: array splatting a nil works, but hash splatting a nil does notRejectedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0