Niklas Konstenius
10/30/2023, 4:06 PMPair
and Triple
for transforming the individual components using a mapping function. This will make the two types more ergonomic to use in a functional programming context. I opened an issue on this here but it seems that there already existed a similar issue.
I'm thinking something like this:
val x = Pair(1,"Hello")
val y = x.mapSecond { it.length }
println(y) // prints (1, 5)
The new extension function is mapSecond
. And there will be a `mapFirst`for Pair also. For Triple I'll add mapFirst
, mapSecond
and mapThird
.
Does this seem like a good idea? What are the chances that a PR will be merged?