Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/compat.rb

Instance Method Summary collapse

Instance Method Details

#product(*enums) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/redis/compat.rb', line 6

def product(*enums)
  enums.unshift self
  result = [[]]
  while [] != enums
    t, result = result, []
    b, *enums = enums
    t.each do |a|
      b.each do |n|
        result << a + [n]
      end
    end
  end
  result
end