Class: Array

Inherits:
Object
  • 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



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/dust/helper.rb', line 5

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