I’m writing a method to wrap another method as part of a class. It needs to both take and pass on an arbitrary number of arguments.
Something like…
def do(*things)
old_method(things)
end
except this won’t work because old_method needs to be passed the contents of the things array as separate arguments rather than as an array.
I just can’t think of a way to do this within ruby syntax…
You can use:
That’s a splat operator, see e.g. What does the (unary) * operator do in this Ruby code? or What's the splat doing here?