From: nobu@... Date: 2018-05-16T07:49:09+00:00 Subject: [ruby-core:87068] [Ruby trunk Feature#14763] Allow more Enumerable methods to accept method names as symbol arguments Issue #14763 has been updated by nobu (Nobuyoshi Nakada). I think that this is not acceptable due to the backward compatibility. `[2].all?(:even?)` returns `false` now, but it would be `true` if this is introduced. The behavior changes from `===` to `send` by the argument class, it doesn't seem very predictable when the argument is not a literal expression. ---------------------------------------- Feature #14763: Allow more Enumerable methods to accept method names as symbol arguments https://bugs.ruby-lang.org/issues/14763#change-72028 * Author: sunnyrjuneja (Sunny Juneja) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- Enumerable has a short hand which accepts method names as symbols. ```ruby (5..10).reduce(:+) #=> 45 ``` I'm proposing we allow the same functionality for #any?, #all?, #find, #reject, #select, #one?, #find_index. I'm requesting this because when I did this earlier today and it did not meet my expectations: ```ruby [2,4,6].all?(:even?) #=> false ``` * Any risk of incompatibility? I don't believe so. As of now, #any? accepts an argument and compares using ===. The following is current behavior: ```ruby [Symbol].any?(:even?) #=> false [:symbol].any?(:even?) #=> false [].all?(:even?) #=> true ``` Thanks for consideration of this request. I've used Ruby for 6 years and this is my first feature request. I understand if it is not a high priority or interesting to the maintainers. I am happy to try to add an implementation if it is interesting. -- https://bugs.ruby-lang.org/ Unsubscribe: