[#106355] [Ruby master Bug#18373] RBS build failure: '/include/x86_64-linux/ruby/config.h', needed by 'constants.o'. — "vo.x (Vit Ondruch)" <noreply@...>
Issue #18373 has been reported by vo.x (Vit Ondruch).
28 messages
2021/12/01
[ruby-core:106462] [Ruby master Feature#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" }
From:
"zverok (Victor Shepelev)" <noreply@...>
Date:
2021-12-03 14:23:50 UTC
List:
ruby-core #106462
Issue #18369 has been updated by zverok (Victor Shepelev).
> Close enough?
Obviously :) But still a "hack". E.g. it is not a "value representing the pattern", this way we can talk ourselves into "we didn't need PM at all, we always could
```ruby
MY_PATTERN = -> { _1[:name] =~ /^B && _1[:age] > 18 }
# ...and
case foo
when -> { _1[:name] =~ /^B && _1[:age] > 18 }
```
:shrug:
----------------------------------------
Feature #18369: users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" }
https://bugs.ruby-lang.org/issues/18369#change-95119
* Author: dorianmariefr (Dorian Mari辿)
* Status: Open
* Priority: Normal
----------------------------------------
Hi,
I was thinking I often do things like `collection.detect { |item| item.attribute == value }` and a shorthand like `collection.detect(:attribute, value)` would be quite useful
What do you think?
And I know there is `collection.detect { _1.attribute == value }` but I try not to use `_1` and this syntax would be shorter and simpler
Could also apply to other methods like `all?` (`collection.all?(:attribute, value)`), and basically any Enumerable method https://rubydoc.info/stdlib/core/Enumerable
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>