catspeake
Splat运算符解压缩传递给函数的数组,以便将每个元素作为单独的参数发送给函数。一个简单的例子:>> def func(a, b, c)>> puts a, b, c>> end=> nil>> func(1, 2, 3) #we can call func with three parameters123=> nil>> list = [1, 2, 3]=> [1, 2, 3]>> func(list) #We CAN'T call func with an array, even though it has three objectsArgumentError: wrong number of arguments (1 for 3) from (irb):12:in 'func' from (irb):12>> func(*list) #But we CAN call func with an unpacked array.123=> nil就这样!