Groovy Tuple Varags

def calculate(String keyInteger..values{
    // Method return a Tuple2 instance.
    new Tuple2(keyvalues.sum())
}
 
// Use multiple assignment to
// extract the values from the tuple.
// Tuple2 has typed objects.
def (String aInteger bcalculate('sum'123)
 
assert == 'sum'
assert == 6

Comments

Popular posts from this blog

தட்டு வண்டியில் காளிக்கோயில் - சிறுகதை

பிரேமாவின் பெண் குழந்தை

தீபம் பிளக்ஸ்