[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:106304] [Ruby master Misc#18352] What is the Hash#grep expected?
From:
"matheusrich (Matheus Richard)" <noreply@...>
Date:
2021-11-28 22:39:21 UTC
List:
ruby-core #106304
Issue #18352 has been updated by matheusrich (Matheus Richard).
Should we have `grep_{keys,values}`?
----------------------------------------
Misc #18352: What is the Hash#grep expected?
https://bugs.ruby-lang.org/issues/18352#change-94930
* Author: zw963 (Wei Zheng)
* Status: Open
* Priority: Normal
----------------------------------------
Current ruby implement, When use Array#grep, the method name means is expected.
```
[19] pry(#<App>)> [:foo1, :foo2, :bar].grep /foo/
[
:foo1,
:foo2
]
```
But when use with hash, the result is really confusing ...
```rb
[12] pry(#<App>)> {foo: '100', bar: '200'}.grep /foo/
[]
```
This result almost make Include Enumerable#grep into Hash is totally meaningless, right?
so, i consider if we should introduce a `Hash#grep` method instead.
Following is what is expected. (=== is matching on hash key, as Hash#slice)
```rb
[20] pry(#<App>)> {foo1: '100', foo2: '200', bar: '200'}.grep /foo/
{
:foo1 => "100",
:foo2 => "200"
}
```
--
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>