Converter função Scala em função Kotlin

Eu sou muito novo no scala Kotlin e estou tentando converter algum código do scala para o Kotlin, apenas como uma maneira de entender algumas coisas.

Um problema com o qual estou tendo problemas é converter essa função scala em uma função Kotlin.

def changeXToDigit(value:String): String = {
   value.map {
      case 'X' => random.nextInt(10).toString
      case letter => letter
   }.mkString
}

Eu sei que não há equivalente mkString no Kotlin, mas imaginei algo como

fun changeXToDigit(value: String):String = {
   value.map { it ->
      when(it) {
        'X' -> random.nextInt(10).toString
        else -> it
   }
}

pode funcionar, mas o IntelliJ reclama e estou um pouco perdido com o erro.

Error:(11, 45) Kotlin: Inferred type is a function type, but a non-function type String was expected. Use either '= ...' or '{ ... }', but not both.

questionAnswers(1)

yourAnswerToTheQuestion