1

I want to use function MutableList<T>.replaceAll(transformation: (T) -> T) in my Android project.

There is a very similar question: Kotlin Extension Functions suddenly require api level 24

But is my case, I want to use the function replaceAll which has identical syntax with Java 8 implementation. So, the question is: how to tell the compiler that I want to use the extension function from Kotlin standard library instead of Java 8 function.

Oknesif
  • 526
  • 5
  • 11
  • what does mean 'identical'? in Kotlin it uses java List.replaceAll method –  Mar 21 '19 at 14:18
  • Java method uses 'UnaryOperator operator' which is identical to 'transformation: (T) -> T' by SAM conversion. – Oknesif Mar 21 '19 at 14:45
  • I do not know why but it looks like `fun MutableList.replaceAll(transformation: (T) -> T)` is only available in [Kotlin Native](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/replace-all.html). – George Mulligan Mar 22 '19 at 13:25

0 Answers0