Tuples in Java
aburkov edited this page Jun 27, 2015
·
1 revision
With xpresso you can use pythonic tuples in your Java code.
Python:
my_car = ("Honda", "red", 2010, True)
xpresso:
tuple myCar = x.tuple("Honda", "red", 2010, true);
Dynamic name assignment to tuple elements:
myCar.name("make","color","year","good");
x.print(myCar.get("good"),myCar.get("make"),myCar.get("year"));
Console: true Honda 2010
If name method has not yet been called, but get(someName) is called for the first time, then the returned value will be get(i), where i is the smallest index of a remaining unnamed element in the tuple. All the subsequent calls for the same value someName, the same element i will be returned by get(someName).