Say I have an array. I wish to pass the array to a function. The function, however, expects two arguments. Is there a way to on the fly convert the array into 2 arguments? F
Use this
a.slice(*b)
It's called the splat operator
You can turn an Array into an argument list with the * (or "splat") operator:
Array
*
a = [0, 1, 2, 3, 4] # => [0, 1, 2, 3, 4] b = [2, 3] # => [2, 3] a.slice(*b) # => [2, 3, 4]