This is something I find myself wanting to do occasionally. Say I have a list of arguments. In Lisp, I can go like
`(imaginary-function ,@args)
in order to call the function with the array turned from one element into the right number of arguments.
Is there similar functionality in Ruby? Or am I just using a completely wrong idiom here?
Yes! It's called the splat operator.
a = [1, 44]
p(*a)
This is the splat operator: function(*list)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With