ruby convert array into function arguments
You can turn an Array
into an argument list with the *
(or "splat") operator:
a = [0, 1, 2, 3, 4] # => [0, 1, 2, 3, 4]b = [2, 3] # => [2, 3]a.slice(*b) # => [2, 3, 4]
You can turn an Array
into an argument list with the *
(or "splat") operator:
a = [0, 1, 2, 3, 4] # => [0, 1, 2, 3, 4]b = [2, 3] # => [2, 3]a.slice(*b) # => [2, 3, 4]