[#69616] [Ruby trunk - Feature #11258] add 'x' mode character for O_EXCL — cremno@...
Issue #11258 has been updated by cremno phobia.
3 messages
2015/06/16
[#69643] [Ruby trunk - Misc #11276] [RFC] compile.c: convert to use ccan/list — normalperson@...
Issue #11276 has been updated by Eric Wong.
3 messages
2015/06/17
[#69751] [Ruby trunk - Bug #11001] 2.2.1 Segmentation fault in reserve_stack() function. — kubo@...
Issue #11001 has been updated by Takehiro Kubo.
3 messages
2015/06/27
[ruby-core:69451] [Ruby trunk - Feature #10017] Add `Hash#fetch_values!`
From:
wojtek@...
Date:
2015-06-02 21:42:15 UTC
List:
ruby-core #69451
Issue #10017 has been updated by Wojtek Mach.
Subject changed from Add `Hash#values_at!` to Add `Hash#fetch_values!`
Hi, please let me know if there's anything I can do to move this ticket forward.
----------------------------------------
Feature #10017: Add `Hash#fetch_values!`
https://bugs.ruby-lang.org/issues/10017#change-52723
* Author: Wojtek Mach
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
----------------------------------------
I'm proposing to add a new method `Hash#values_at!` that's basically a combination of `#values_at` and `#fetch`.
When dealing with configuration I prefer to use `#fetch` to fail early and this would be useful to read multiple keys at a time.
An example (not strictly on a Hash, but you get the idea) could be:
```ruby
repo, token = ENV.values_at!('GITHUB_REPO', 'GITHUB_TOKEN')
ENV.values_at!('INVALID') # raises KeyError
# not sure if that useful, but I provide it here for the sake of completeness
ENV.values_at!("SHELL", "INVALID") { |k| k + " is missing" } # => ["/bin/bash", "INVALID is missing"]
```
Another name for this could be `#fetch_at`, perhaps.
P.S. I'm attaching a patch that was done using mostly trial and error
---Files--------------------------------
values_at_bang.patch (1.53 KB)
fetch_at.patch (2.18 KB)
--
https://bugs.ruby-lang.org/