Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/array_zip_with/core_ext/array.rb
Overview
Instance Method Summary collapse
Instance Method Details
#zip_with(*args, &block) ⇒ Array #zip_with(*args, operator) ⇒ Array
30 31 32 33 34 35 36 |
# File 'lib/array_zip_with/core_ext/array.rb', line 30 def zip_with(*args) return zip(*args).map(&Proc.new) if block_given? operator = args.pop raise ArgumentError, "A block or symbol \ must be provided" unless operator.is_a?(Symbol) zip(*args).map { |elems| elems.reduce(operator) } end |