//arrow-fx-stm/arrow.fx.stm/STM/transform

transform

common open fun <A> TArray<A>.transform(f: (A) -> A)

Modify each element in a TArray by applying f.

import arrow.fx.stm.TArray
import arrow.fx.stm.atomically

suspend fun main() {
  //sampleStart
  val tarr = TArray.new(size = 10, 2)
  val result = atomically {
    tarr.transform { it + 1 }
  }
  //sampleEnd
}

This function never retries.

Do you like Arrow?

Arrow Org
<