fork download
  1. require 'pp'
  2.  
  3. a = [1, 2, 3, 4, 5, 6]
  4. b = [1, 2, 3, 4, 5, 6]
  5. c = []
  6.  
  7. a.each_with_index do |ai, i|
  8. b.each_with_index do |bj, j|
  9. c[i] ||= []
  10. c[i][j] = ai * bj
  11. end
  12. end
  13.  
  14. pp a
  15. pp b
  16. pp c
Success #stdin #stdout 0.02s 10080KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
[[1, 2, 3, 4, 5, 6],
 [2, 4, 6, 8, 10, 12],
 [3, 6, 9, 12, 15, 18],
 [4, 8, 12, 16, 20, 24],
 [5, 10, 15, 20, 25, 30],
 [6, 12, 18, 24, 30, 36]]