Class: Array

Inherits:
Object show all
Defined in:
lib/dust/helper.rb

Overview

combines two arrays stolen from Juan Matias (jmrepetti) from stackoverflow.com

Instance Method Summary collapse

Instance Method Details

#combine(a) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dust/helper.rb', line 12

def combine a
  return a if self.empty?
  return self if a.empty?

  aux = []
  self.each do |self_elem|
    a.each do |other_elem|
      aux << [ self_elem, other_elem ]
    end
  end
  aux.map {|elem| elem.flatten }
end