Sha256: deeef1fe5a2d8deec0b3ac0341ea6bf4f0dff27d3527b78ebb8e96d9801950c7
Contents?: true
Size: 514 Bytes
Versions: 2
Compression:
Stored size: 514 Bytes
Contents
require_relative "iterate/version" module Kernel private def iterate(*iteratables) raise ArgumentError, "wrong number of arguments (0)" if iteratables.empty? first, rest = iteratables[0], iteratables[1..-1] if rest.empty? block_given? ? first.map{ |e| yield e } : first.map.to_enum else padding = iteratables.max_by(&:size).size - first.size iter = (first.to_a + [nil]*padding).zip(*rest) block_given? ? iter.map{|es| yield(*es) } : iter.map.to_enum end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iterate-1.0.1 | lib/iterate.rb |
iterate-1.0.0 | lib/iterate.rb |