ActionsLike0
Feature #18369
openusers.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" }
Status:
Open
Assignee:
-
Target version:
-
Description
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
Updated by dorianmariefr (Dorian Marié) over 3 years ago
- Backport deleted (
2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN) - Tracker changed from Bug to Feature
ActionsLike0