[#70257] [Ruby trunk - Feature #11420] [Open] Introduce ID key table into MRI — ko1@...

Issue #11420 has been reported by Koichi Sasada.

11 messages 2015/08/06

[ruby-core:70261] [Ruby trunk - Bug #11048] blocks raise on missing and extra keyword args

From: alxtskrnk@...
Date: 2015-08-06 17:50:01 UTC
List: ruby-core #70261
Issue #11048 has been updated by bug hit.


bug hit wrote:
> another use case for this is hash destructuring
> 
> ```
> array_of_hashes.each do |key1:, key2:|
> end
> ```
> 
> it would be much better if this code did not raise on extra or missing keys, otherwise this type of destructuring is almost completely impractical

Please comment on the use case of hash destructuring via block keyword args.


----------------------------------------
Bug #11048: blocks raise on missing and extra keyword args
https://bugs.ruby-lang.org/issues/11048#change-53686

* Author: bug hit
* Status: Rejected
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
blocks intentionally tolerate arity mismatches

```
irb(main):001:0> proc{|a, b| [a, b]}.(1)
[
  [0] 1,
  [1] nil
]

irb(main):003:0> proc{|a, b|[a, b]}.(1, 2, 3)
[
  [0] 1,
  [1] 2
]


```

so why not missing keyword args?

```
irb(main):002:0> proc{|a:, b:|[a, b]}.(a: 1)
ArgumentError: missing keyword: b


irb(main):004:0> proc{|a:, b:|[a, b]}.(a: 1, b: 1, c: 1)
ArgumentError: unknown keyword: c

```




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

In This Thread

Prev Next