From: "chucke (Tiago Cardoso) via ruby-core" Date: 2026-05-04T05:52:34+00:00 Subject: [ruby-core:125397] [Ruby Bug#22021] Array#delete_if may delete wrong object if array has been altered already Issue #22021 has been reported by chucke (Tiago Cardoso). ---------------------------------------- Bug #22021: Array#delete_if may delete wrong object if array has been altered already https://bugs.ruby-lang.org/issues/22021 * Author: chucke (Tiago Cardoso) * Status: Open * ruby -v: 4.0.2 * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- The simplest example I can come up with: ```ruby $ar = ar = [1, 2, 3, 4, 5] def delete_at(i) $ar.delete(i) end ar.delete_if { |i| i == 2 ? (delete_ar(i) && true) : false } ar #=> [1, 4, 5], and it should be [1, 3, 4, 5] ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/