I have a Seq of Tuple3 elements.
I want a resulting collection (probably a Set) made up with the second element of each tuple.
For example
(a, b, c), (d, e, f), (g, h, i) ==> (b, e, h)
Any idea? I searched a lot but all I’m finding has to do with filtering on the tuples, not within them, if that makes any sense.
I’m still quite new to Scala, learning is a long process 🙂 Thanks for your help.
yourSeqOfTuples.map(tuple => tuple._2).toSet, which may be shortedned toyourSeqOfTuples.map(_._2).toSetYou may use {} rather than () if you prefer it so.
_2is the method which gets the second element of the tuple.