Method: Enumerable#drop_while
- Defined in:
- enum.c
#drop_while {|arr| ... } ⇒ Array #drop_while ⇒ Object
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.
a = [1, 2, 3, 4, 5, 0]
a.drop_while { |i| i < 3 } #=> [3, 4, 5, 0]
2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 |
# File 'enum.c', line 2273 static VALUE enum_drop_while(VALUE obj) { VALUE result; NODE *memo; RETURN_ENUMERATOR(obj, 0, 0); result = rb_ary_new(); memo = NEW_MEMO(result, 0, FALSE); rb_block_call(obj, id_each, 0, 0, drop_while_i, (VALUE)memo); return result; } |