In Python and C#, if you have a tuple/list you can unpack it with the following:
tup = (1, 3)
a, b = tup
Then a = 1
and b = 3
.
It seems to me that Java doesn't have tuples, but if I have a Vector
or primitive []
array of known size, is there a similar unpacking idiom for arrays/vectors in Java? At the moment I am using the below solution.
a = arr[0]
b = arr[1]
Where arr is a stand-in for a real tuple.
I'm open to any answer which accomplishes a similar behavior, even if it involves external libraries/additional classes/etc