From: "matz (Yukihiro Matsumoto) via ruby-core" Date: 2023-12-20T08:16:14+00:00 Subject: [ruby-core:115809] [Ruby master Feature#20049] Destructive drop_while for Array and Hash Issue #20049 has been updated by matz (Yukihiro Matsumoto). Status changed from Open to Feedback I reject `Hash#drop_while!` because the order is not (and should not be) important for Hash and the order of hash is fragile anyway. Whereas `Array#drop_while!` has chance. Could you explain the use-case for the new method, please? Matz. ---------------------------------------- Feature #20049: Destructive drop_while for Array and Hash https://bugs.ruby-lang.org/issues/20049#change-105758 * Author: chucke (Tiago Cardoso) * Status: Feedback * Priority: Normal ---------------------------------------- I propose a "drop_while!" variant for arrays and hashes, which changes the current instance. ```ruby h = {foo: 0, bar: 1, baz: 2} h.drop_while!{|element| key, value = *element; value < 2 } h #=> # => { baz: 2 } ``` -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/