Mega Code Archive

 
Categories / Ruby / Collections
 

Add cartesian to Enumerable

module Enumerable   def cartesian(other)     inject([]) { |res, x| other.inject(res) { |res, y| res << [x,y] } }   end end