我有一个数组(更精确的嵌套数组),如下所示:
[["Armando", "P"], ["Dave", "S"], ["Richard", "R"], ["Michael", "S"],
["Allen", "S"], ["Omer", "P"], ["David E.", "R"], ["Richard X.", "P"]]
我希望一次将两个元组作为参数传递给另一个函数,例如:
rps_result(["Armando", "P"], ["Dave", "S"])
rps_result(["Richard", "R"], ["Michael", "S"])
我正在尝试这样做,因为我遍历我的数组:
arr.each_slice(2) do |first, second|
rps_game_winner([first, second])
end
但是,当我打印参数的值时,这并没有给出所需的答案。我在这里做错了什么?
答案 0 :(得分:1)
只需删除参数上的方括号:
arr.each_slice(2) { |first, second| fun(first, second) }