Project

General

Profile

Bug #15957

Splatting nil as **kwargs

Added by Tietew (Toru Iwase) 6 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0dev (2019-06-24T15:19:49Z trunk e09afd15b7) [x86_64-linux]
[ruby-core:93354]

Description

Splatting nil as *array is ignored silently.

[1, *nil]
# => [1, 2]

But splatting nil as **kwargs raises TypeError.

{foo: 1, **nil}
# => no implicit conversion of nil into Hash (TypeError)

Is this intentional?


Related issues

Is duplicate of Ruby master - Bug #15078: Hash splat of empty hash should not create a positional argument.ClosedActions

History

#1

Updated by nobu (Nobuyoshi Nakada) 6 months ago

  • Is duplicate of Bug #15078: Hash splat of empty hash should not create a positional argument. added
#2

Updated by jeremyevans0 (Jeremy Evans) 4 months ago

  • Status changed from Open to Closed

Fixed by #14183:

$ ruby -e 'def foo(*args); p args; end; foo(**{}); foo(**Hash.new) '
[]
[]

Also available in: Atom PDF