7 # enum.drop(n) -> array
9 # Drops first n elements from <i>enum</i>, and returns rest elements
12 # a = [1, 2, 3, 4, 5, 0]
13 # a.drop(3) #=> [4, 5, 0]
16 raise TypeError, "expected Integer for 1st argument" unless n.kind_of? Integer
17 raise ArgumentError, "attempt to drop negative size" if n < 0
20 self.each {|*val| n == 0 ? ary << val.__svalue : n -= 1 }
26 # enum.drop_while {|arr| block } -> array
28 # Drops elements up to, but not including, the first element for
29 # which the block returns +nil+ or +false+ and returns an array
30 # containing the remaining elements.
32 # a = [1, 2, 3, 4, 5, 0]
33 # a.drop_while {|i| i < 3 } #=> [3, 4, 5, 0]
35 def drop_while(&block)
36 ary, state = [], false
38 state = true if !state and !block.call(*val)
39 ary << val.__svalue if state
46 # enum.take(n) -> array
48 # Returns first n elements from <i>enum</i>.
50 # a = [1, 2, 3, 4, 5, 0]
51 # a.take(3) #=> [1, 2, 3]
54 raise TypeError, "expected Integer for 1st argument" unless n.kind_of? Integer
55 raise ArgumentError, "attempt to take negative size" if n < 0
59 break if ary.size >= n