From: "nobu (Nobuyoshi Nakada)" Date: 2021-12-02T06:00:13+00:00 Subject: [ruby-core:106380] [Ruby master Feature#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } Issue #18369 has been updated by nobu (Nobuyoshi Nakada). Since `Enumerable#detect` or `Enumerable#find` has the argument for the different purpose, I think that the extension in this way is not acceptable and should be a separate method. The "arguments after a block" is one of rejected ideas before the numbered parameters. ---------------------------------------- Feature #18369: users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } https://bugs.ruby-lang.org/issues/18369#change-95016 * 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: