我有一个接受splat运算符的方法:
def hello(foo, *bar)
#... do some stuff
end
Run Code Online (Sandbox Code Playgroud)
我有一个可变长度的数组,我想发送到这个hello方法:
arr1 = ['baz', 'stuff']
arr2 = ['ding', 'dong', 'dang']
Run Code Online (Sandbox Code Playgroud)
我想用arr1和arr2作为该方法的参数来调用该方法,但我不断被挂起,因为*bar被解释为数组而不是单个参数.为了让事情更有趣,我根本无法更改hello方法.
我正在寻找类似于这个问题但在红宝石中的东西.