【发布时间】:2014-07-29 01:40:46
【问题描述】:
在调用方法时如何计算作为 splat 参数传递的值的数量?
def splat_demo(*var)
#code to find out no of values in the splat variable here
end
【问题讨论】:
在调用方法时如何计算作为 splat 参数传递的值的数量?
def splat_demo(*var)
#code to find out no of values in the splat variable here
end
【问题讨论】:
您会得到一个数组,因此只需运行 var.size 即可获取传入的值的数量。
【讨论】:
Array。