* [ruby-core:124198] [Ruby Feature#21781] Add `fetch_values` method on `ENV`
@ 2025-12-14 18:33 Earlopain (Earlopain _) via ruby-core
2026-02-12 7:35 ` [ruby-core:124779] " matz (Yukihiro Matsumoto) via ruby-core
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2025-12-14 18:33 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #21781 has been reported by Earlopain (Earlopain _).
----------------------------------------
Feature #21781: Add `fetch_values` method on `ENV`
https://bugs.ruby-lang.org/issues/21781
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
In https://bugs.ruby-lang.org/issues/10017, `fetch_values` was introduced for `Hash`. `ENV` is hash-like but is missing the method. Here are the differences between hash and env right now:
```rb
irb(main):006> Hash.instance_methods - ENV.methods
=>
[:merge,
:compare_by_identity,
:compare_by_identity?,
:>=,
:deconstruct_keys,
:dig,
:<=,
:>,
:<,
:to_proc,
:flatten,
:compact!,
:default=,
:default_proc,
:default_proc=,
:default,
:transform_keys,
:transform_keys!,
:transform_values!,
:fetch_values,
:transform_values]
```
`flatten`/`dig` among others make no sense for `ENV`. Some I don't see why they are not present but I won't argue for them since I have no use-case.
Here is code I wanted to write:
```rb
# Get many env variables and crash if one is missing
user, pass, year, target_dir = ENV.fetch_values("USER", "PASS", "YEAR", "TARGET_DIR")
```
For now I am simply adding `to_h` and all is good. But should I have to? Ignoring a small amount of methods, ENV is very close to a hash already.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:124779] [Ruby Feature#21781] Add `fetch_values` method on `ENV`
2025-12-14 18:33 [ruby-core:124198] [Ruby Feature#21781] Add `fetch_values` method on `ENV` Earlopain (Earlopain _) via ruby-core
@ 2026-02-12 7:35 ` matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 8:20 ` [ruby-core:124788] " matz (Yukihiro Matsumoto) via ruby-core
2026-02-14 21:50 ` [ruby-core:124823] " Earlopain (Earlopain _) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2026-02-12 7:35 UTC (permalink / raw)
To: ruby-core; +Cc: matz (Yukihiro Matsumoto)
Issue #21781 has been updated by matz (Yukihiro Matsumoto).
Accepted.
Matz.
----------------------------------------
Feature #21781: Add `fetch_values` method on `ENV`
https://bugs.ruby-lang.org/issues/21781#change-116390
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
In https://bugs.ruby-lang.org/issues/10017, `fetch_values` was introduced for `Hash`. `ENV` is hash-like but is missing the method. Here are the differences between hash and env right now:
```rb
irb(main):006> Hash.instance_methods - ENV.methods
=>
[:merge,
:compare_by_identity,
:compare_by_identity?,
:>=,
:deconstruct_keys,
:dig,
:<=,
:>,
:<,
:to_proc,
:flatten,
:compact!,
:default=,
:default_proc,
:default_proc=,
:default,
:transform_keys,
:transform_keys!,
:transform_values!,
:fetch_values,
:transform_values]
```
`flatten`/`dig` among others make no sense for `ENV`. Some I don't see why they are not present but I won't argue for them since I have no use-case.
Here is code I wanted to write:
```rb
# Get many env variables and crash if one is missing
user, pass, year, target_dir = ENV.fetch_values("USER", "PASS", "YEAR", "TARGET_DIR")
```
For now I am simply adding `to_h` and all is good. But should I have to? Ignoring a small amount of methods, ENV is very close to a hash already.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:124788] [Ruby Feature#21781] Add `fetch_values` method on `ENV`
2025-12-14 18:33 [ruby-core:124198] [Ruby Feature#21781] Add `fetch_values` method on `ENV` Earlopain (Earlopain _) via ruby-core
2026-02-12 7:35 ` [ruby-core:124779] " matz (Yukihiro Matsumoto) via ruby-core
@ 2026-02-12 8:20 ` matz (Yukihiro Matsumoto) via ruby-core
2026-02-14 21:50 ` [ruby-core:124823] " Earlopain (Earlopain _) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: matz (Yukihiro Matsumoto) via ruby-core @ 2026-02-12 8:20 UTC (permalink / raw)
To: ruby-core; +Cc: matz (Yukihiro Matsumoto)
Issue #21781 has been updated by matz (Yukihiro Matsumoto).
I accept the proposal.
Matz.
----------------------------------------
Feature #21781: Add `fetch_values` method on `ENV`
https://bugs.ruby-lang.org/issues/21781#change-116400
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
In https://bugs.ruby-lang.org/issues/10017, `fetch_values` was introduced for `Hash`. `ENV` is hash-like but is missing the method. Here are the differences between hash and env right now:
```rb
irb(main):006> Hash.instance_methods - ENV.methods
=>
[:merge,
:compare_by_identity,
:compare_by_identity?,
:>=,
:deconstruct_keys,
:dig,
:<=,
:>,
:<,
:to_proc,
:flatten,
:compact!,
:default=,
:default_proc,
:default_proc=,
:default,
:transform_keys,
:transform_keys!,
:transform_values!,
:fetch_values,
:transform_values]
```
`flatten`/`dig` among others make no sense for `ENV`. Some I don't see why they are not present but I won't argue for them since I have no use-case.
Here is code I wanted to write:
```rb
# Get many env variables and crash if one is missing
user, pass, year, target_dir = ENV.fetch_values("USER", "PASS", "YEAR", "TARGET_DIR")
```
For now I am simply adding `to_h` and all is good. But should I have to? Ignoring a small amount of methods, ENV is very close to a hash already.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:124823] [Ruby Feature#21781] Add `fetch_values` method on `ENV`
2025-12-14 18:33 [ruby-core:124198] [Ruby Feature#21781] Add `fetch_values` method on `ENV` Earlopain (Earlopain _) via ruby-core
2026-02-12 7:35 ` [ruby-core:124779] " matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 8:20 ` [ruby-core:124788] " matz (Yukihiro Matsumoto) via ruby-core
@ 2026-02-14 21:50 ` Earlopain (Earlopain _) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2026-02-14 21:50 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #21781 has been updated by Earlopain (Earlopain _).
https://github.com/ruby/ruby/pull/16177
----------------------------------------
Feature #21781: Add `fetch_values` method on `ENV`
https://bugs.ruby-lang.org/issues/21781#change-116444
* Author: Earlopain (Earlopain _)
* Status: Open
----------------------------------------
In https://bugs.ruby-lang.org/issues/10017, `fetch_values` was introduced for `Hash`. `ENV` is hash-like but is missing the method. Here are the differences between hash and env right now:
```rb
irb(main):006> Hash.instance_methods - ENV.methods
=>
[:merge,
:compare_by_identity,
:compare_by_identity?,
:>=,
:deconstruct_keys,
:dig,
:<=,
:>,
:<,
:to_proc,
:flatten,
:compact!,
:default=,
:default_proc,
:default_proc=,
:default,
:transform_keys,
:transform_keys!,
:transform_values!,
:fetch_values,
:transform_values]
```
`flatten`/`dig` among others make no sense for `ENV`. Some I don't see why they are not present but I won't argue for them since I have no use-case.
Here is code I wanted to write:
```rb
# Get many env variables and crash if one is missing
user, pass, year, target_dir = ENV.fetch_values("USER", "PASS", "YEAR", "TARGET_DIR")
```
For now I am simply adding `to_h` and all is good. But should I have to? Ignoring a small amount of methods, ENV is very close to a hash already.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-14 21:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-14 18:33 [ruby-core:124198] [Ruby Feature#21781] Add `fetch_values` method on `ENV` Earlopain (Earlopain _) via ruby-core
2026-02-12 7:35 ` [ruby-core:124779] " matz (Yukihiro Matsumoto) via ruby-core
2026-02-12 8:20 ` [ruby-core:124788] " matz (Yukihiro Matsumoto) via ruby-core
2026-02-14 21:50 ` [ruby-core:124823] " Earlopain (Earlopain _) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).