2
可变数量的产品是有一个Java等同于Ruby的数组#产品的方法,或这样做的方式:查找字符串数组中的Java
groups = [
%w[hello goodbye],
%w[world everyone],
%w[here there]
]
combinations = groups.first.product(*groups.drop(1))
p combinations
# [
# ["hello", "world", "here"],
# ["hello", "world", "there"],
# ["hello", "everyone", "here"],
# ["hello", "everyone", "there"],
# ["goodbye", "world", "here"],
# ["goodbye", "world", "there"],
# ["goodbye", "everyone", "here"],
# etc.
这个问题是这样的一个的Java版本:Finding the product of a variable number of Ruby arrays
非常好,谢谢。 – 2010-09-20 11:56:39