Is there a `mapFirst` method or something like it ...
# getting-started
m
Is there a
mapFirst
method or something like it that I can use to apply a function to each
Pair<T, U>
in a sequence/collection/etc to map to a
Pair<V, U>
?
v
Not that I know of, but you can easily create one yourself:
Copy code
fun <X, Y, Z> Iterable<Pair<X, Y>>.mapFirst(transform: (X) -> Z) =
    map { (x, y) -> Pair(transform(x), y) }
❤️ 3