Hi there!. Is there something similar to tap funct...
# arrow
a
Hi there!. Is there something similar to tap function in Arrow? that is execute a side effect action with the value of a container and return the input of the original container. Example:
Copy code
getResultFromDatabase().tap { result ->
  log(result)
}.map { result ->
  transformDatabaseResult()
}
I know it can be done using map and returning the same input as output but tap is making clearer that there is a side effect there
s
Hey @Alvaro Blazquez checa, Yes, there is
tap
and
tapLeft
available on
Either
for example. It should also be present on the other data types, if not feel free to create a ticket or raise a PR 😉 https://github.com/arrow-kt/arrow/blob/main/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt#L853
a
Great Simon. thx!
c
very interesting the
tap
function, I always have been using
map
...
s
It’s been only recently added. Right before 1.0 @carbaj0
👍 4