请问,实现下面功能的内建方法有吗?
def combine *arrays
if arrays.length == 0
yield []
else
arrays.pop.each do |n|
combine *arrays do |x|
yield x.push n
end
end
end
end
combine %w{a b}, %w{A B} do |x| p x end
# result
# ["a", "A"]
# ["b", "A“]
# [”a", "B"]
# ["b", "B"]