0

如何在调用方法时计算作为 splat 参数传递的值的数量?

def splat_demo(*var)
   #code to find out no of values in the splat variable here
end
4

1 回答 1

1

你得到一个数组,所以只需运行var.size以获取传入的值的数量。

于 2014-06-08T09:15:28.757 回答