Sending elements of an array as arguments to a method call
- by Bryce
I have a method that accepts the splat operator:
def hello(foo, *bar)
#... do some stuff
end
I have an array with a variable length that I'd like to send into this hello method:
arr1 = ['baz', 'stuff']
arr2 = ['ding', 'dong', 'dang']
I'd like to call the method with arr1 and arr2 as arguments to that method but I keep getting hung up in that *bar is being interpreted as an array instead of individual arguments. To make things more fun, I can't change the hello method at all.
I'm looking for something similar to this SO question but in ruby.