Sha256: e679ecd5c662de37d3b74aa5c7c10e02f90a38de527ac598cb9bdf6e894c60b8
Contents?: true
Size: 811 Bytes
Versions: 16
Compression:
Stored size: 811 Bytes
Contents
class Enumerator # combine with_index and with_object # @see with_index, with_object # # @example # (1..7).each.with_iobject([]){|(*args), idx, memo|} # (1..7).each.with_iobject(2, []){|(*args), idx, memo|} # offset is 2 # # @overload with_iobject(*args) # @param [Fixnum,Object] *args pass Fixnum as offset, otherwise as memo_obj # @return Enumerator # # @overload with_iobject(*args) # @yieldparam [Object] (*args) # @yieldparam [Fixnum] idx index # @yieldparam [Object] memo_obj def with_iobject *args, &blk return self.to_enum(:with_iobject, *args) unless blk offset = args.find!{|v| Fixnum===v} || 0 raise ArgumentError "must provide memo_obj" if args.empty? memo = args[0] i = offset-1 self.with_object memo do |args, m| blk.call args,i+=1,m end end end
Version data entries
16 entries across 16 versions & 1 rubygems