Ruby 的 splat 运算符*
可用于合并
def one_argument(*a)
...
end
one_argument(1, 2, 3)
或分裂
def multiple_arguments(a, b, c)
...
end
multiple_arguments(*[1, 2, 3])
多个值,具体取决于上下文。
是否有可能创建一个充当“反向 splat”运算符的方法?要充当逆,运算符必须满足:
inverse_splat(*(foo)) == foo
和
*(inverse_splat(foo)) == foo