drop_while()
public
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.
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 }
Show source
/*
* call-seq:
* ary.drop_while {|arr| block } => array
*
* 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.
*
* a = [1, 2, 3, 4, 5, 0]
* a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
*
*/
static VALUE
rb_ary_drop_while(ary)
VALUE ary;
{
long i;
RETURN_ENUMERATOR(ary, 0, 0);
for (i = 0; i < RARRAY(ary)->len; i++) {
if (!RTEST(rb_yield(RARRAY(ary)->ptr[i]))) break;
}
return rb_ary_drop(ary, LONG2FIX(i));
}