I have:
List<Tuple2<String, String>> listOfTuples
I would like to have a list of second elements from each Tuple2
Eg.
[Tuple2('1','foo'), Tuple2('2','bar')]
to
['foo','bar']
It's easy. You can use Groovy' spread operator to extract a list of the tuple's second elements.
Consider the following example:
def list = [new Tuple2('1','foo'), new Tuple2('2','bar')]
assert ['foo', 'bar'] == list*.second