From: hanmac@... Date: 2018-07-02T07:45:40+00:00 Subject: [ruby-core:87740] [Ruby trunk Feature#14887] Array#delete_if does not use #delete Issue #14887 has been updated by Hanmac (Hans Mackowiak). I don't think there is a way: ~~~ ruby a = [1,2,3,2,5] a.delete_if {|x| x == 2} a #=> [1,3,5] ~~~ this might call delete, but what about this? ~~~ ruby a = [1,2,3,2,5] a.delete_if.with_index { |x,i| x == 2 && i == 1 } a #=> [1,3,2,5] ~~~ as you can see, you can't make `delete_if` call `delete` without breaking other code ---------------------------------------- Feature #14887: Array#delete_if does not use #delete https://bugs.ruby-lang.org/issues/14887#change-72759 * Author: sdaubert (Sylvain Daubert) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- When a class inherits from Array, and its #delete methods is modified, #delete_if and #reject! do not call this method. From sources, its an internal C method which is called instead. Is there a way to modify #delete_if and #reject! to use #delete? This would ease inheriting of Array class. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>