Hi, how are `generator-scripts/tuple.generator.kt...
# arrow
s
Hi, how are
generator-scripts/tuple.generator.kts
run in the arrow build? I'd like to add mapN to nullable tuples
s
It has not been used in a long time anymore, and it should be removed. We’ve been manually implementing stuff in tuples directly for a while already.
What do you mean with nullable tuples?
Those files can be run as Kotlin Scripts.
s
like
Copy code
internal fun <A, B, R> Pair<A?, B?>.mapN(f: (A, B) -> R): R? =
      first?.let { first_ ->
        second?.let { second_ ->
          f(first_, second_)
        }
      }
s
You can use
Nullable.zip
although it’s a little bit less convenient.
Copy code
Nullable.zip(
  pair.first,
  pair.second
) { a, b -> ... }
It’s an n-arity DSL for avoiding nested
?.let
There is also
nullable { }
which allows to call
fun A?.bind(): A
s
cool. This is what I was looking for
thanks
👍 1