Project

General

Profile

Bug #8507

Keyword splat does not convert arg to Hash

Added by stephencelis (Stephen Celis) about 7 years ago. Updated 7 months ago.

Status:
Rejected
Priority:
Normal
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

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

Also available in: Atom PDF