End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Enumerable#drop_while
enum.drop_while { |obj| block } → array
enum.drop_while → an_enumerator
enum.c
View on GitHub ↗
static VALUE
enum_drop_while(VALUE obj)
{
VALUE result;
struct MEMO *memo;
RETURN_ENUMERATOR(obj, 0, 0);
result = rb_ary_new();
memo = MEMO_NEW(result, 0, FALSE);
rb_block_call(obj, id_each, 0, 0, drop_while_i, (VALUE)memo);
return result;
}
Drops elements up to, but not including, the first element for which the block returns nil or false and returns an array containing the remaining elements.
If no block is given, an enumerator is returned instead.
Example
a = [1, 2, 3, 4, 5, 0] a.drop_while { |i| i < 3 } #=> [3, 4, 5, 0]