Let's say I have an array [2, 3]
, and I want to pass that into a function. Not as function([2, 3])
, as function(2, 3)
. Is there anyway to do that, like
function(pass(array))
?
Asked
Active
Viewed 368 times
0

wyatt-stanke
- 48
- 4
-
5Did you mean `function(*array)`? – quamrana Oct 16 '20 at 15:46
-
2Does this answer your question? [What does \*\* (double star/asterisk) and \* (star/asterisk) do for parameters?](https://stackoverflow.com/questions/36901/what-does-double-star-asterisk-and-star-asterisk-do-for-parameters) – James Oct 16 '20 at 15:50
-
Yes! Thank you quamrana and James! – wyatt-stanke Oct 16 '20 at 17:21
1 Answers
1
Check this out (it utilizes the unpacking operator *
):
array = [2, 3]
function(*array)

Seth
- 2,214
- 1
- 7
- 21