min
09/30/2026, 7:18 AMfun <L, R> left(pair: Pair<L, R>): L { return pair.first }
fun <L, R> right(pair: Pair<L, R>): R { return pair.second }
pairs.map(::left)
I can do this to transform a List<Pair<A, B>> into a List<A>.
pairs.map(Pair::first)
I’d like to not have to define my own functions however. I’ve tried the following but they all don’t work:
• Pair::first doesn’t compile.
• Pair<*, *>::first compiles but returns a List<*>.
• Pair<VeryLongTypeName, *>::first compiles but is verbose and brittle.
What should I do?Alejandro Serrano.Mena
09/30/2026, 10:54 AMpairs.map { it.first } , or even pairs.map { [x, _] -> x }CLOVIS
09/30/2026, 2:01 PMCLOVIS
09/30/2026, 2:02 PMpairs.map { it.first }