Module: Digiproc::CoreExtensions::ArrayExtension::Multiply
- Defined in:
- lib/extensions/core_extensions.rb
Overview
Multiply two arrays element by element. They must be the same size myArray.times(anotherArr) => Array (same size as the input)
Instance Method Summary collapse
Instance Method Details
#times(arr) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/extensions/core_extensions.rb', line 36 def times(arr) raise ArgumentError.new("Array sizes must be equal") if self.size != arr.size output = [] self.each_with_index do |o,i| output << o * arr[i] end output end |