From bb0e42c5e706f238dce40abb9cf5322e4a8a73cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 15 Dec 2025 14:36:53 +0100 Subject: [PATCH] Define Array#detect as an alias for Array#find Otherwise Array#detect is Enumerable#detect while Array#find uses a different more performant implementation. [Feature #21678] --- array.c | 1 + 1 file changed, 1 insertion(+) diff --git a/array.c b/array.c index 1352b5c046..b9d91d0a9b 100644 --- a/array.c +++ b/array.c @@ -8910,6 +8910,7 @@ Init_Array(void) rb_define_method(rb_cArray, "size", rb_ary_length, 0); rb_define_method(rb_cArray, "empty?", rb_ary_empty_p, 0); rb_define_method(rb_cArray, "find", rb_ary_find, -1); + rb_define_method(rb_cArray, "detect", rb_ary_find, -1); rb_define_method(rb_cArray, "rfind", rb_ary_rfind, -1); rb_define_method(rb_cArray, "find_index", rb_ary_index, -1); rb_define_method(rb_cArray, "index", rb_ary_index, -1);