假设我有一个需要三个参数的方法:
def foo(a, b, c)
end
我已经说过数组中的参数:
[a, b, c]
是否有使用数组作为参数的简单方法或一种方法,例如:
foo(array.some_method)
最佳答案
您可以使用 splat operator :
foo(*array)
关于ruby-on-rails - 有没有办法通过数组将多个参数输入到方法中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15907525/