Issue #15078 has been updated by marcandre (Marc-Andre Lafortune).


akr (Akira Tanaka) wrote:
> How about def `m(**kw) end` binds kw to nil if the last Hash argument is not taken as keyword arguments and
> `m(**{})` add {} and `m(**nil)` don't add anything to arguments.

Very clever :-)

As Mame-san points out, it would be a source of incompatibility. I would really like to know how big though.

I imagine that most cases of `**h` capture are used to forward them (so no incompatibility).

I looked at `DeepCover`'s code:
34 cases of `def foo(... **option)`
26 are ok (about 22 simply forward **option)
8 are incompatible (2 of which were simply missing hash splat)
An example: https://github.com/deep-cover/deep-cover/blob/master/core_gem/lib/deep_cover/tools/content_tag.rb#L6-L9


----------------------------------------
Bug #15078: Hash splat of empty hash should not create a positional argument.
https://bugs.ruby-lang.org/issues/15078#change-74077

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: ruby 2.6.0dev (2018-08-27 trunk 64545) [x86_64-darwin15]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Looks like #10856 is not completely fixed, but I can't reopen it

```
def foo(*args); args; end
foo(**{}) # => []
foo(**Hash.new) # => [{}], should be []
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>