Issue #21857 has been reported by sanfrecce-osaka (Masatoshi Moritsuka). ---------------------------------------- Feature #21857: Introduce to_proc pattern https://bugs.ruby-lang.org/issues/21857 * Author: sanfrecce-osaka (Masatoshi Moritsuka) * Status: Open ---------------------------------------- When object has some logics, we can use `&object` syntax with Enumerable or Array, etc. ```ruby users.any?(&:admin?) ``` There are some times when I want to write pattern matching similar to the syntax, but currently we either have to write proc or combine pin operator with `to_proc`, which is a bit verbose. ```ruby users in [*, ^(:admin?.to_proc), *] users in [*, -> (user) { user.admin? }, *] ``` Therefore, I propose introducing a new pattern into pattern matching. The pattern matches an object such that `pattern.to_proc === object`. This allows us to write code with a familiarity close to the syntax we're accustomed to. ```ruby users in [*, &:admin?, *] ``` -- https://bugs.ruby-lang.org/