
Issue #20049 has been updated by zverok (Victor Shepelev).
Could you explain the use-case for the new method, please?
Not the original author, but I think one of the frequent use cases is some parser- or scanner-alike code. E.g., after reading some "dirty" data, ```ruby lines.drop_while! { ln.match?(/HEADER:/) } # operate with clean `lines` here ``` (I had more generic take on this in my ticket about "consuming" enumerators #19061, which I haven't had time to pursue the better proposal/explanation this year, but want to return during the next one.) ---------------------------------------- Feature #20049: Destructive drop_while for Array and Hash https://bugs.ruby-lang.org/issues/20049#change-105764 * 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/