```private val rngs: MutableList<IntRange> = mutab...
# codereview
b
Copy code
private val rngs: MutableList<IntRange> = mutableListOf(1..2, 3..4, 5..6)

fun process(repl: Array<String>): String {                                                                                               
    if (repl.size != rngs.size) throw RuntimeException("${repl.size} != ${rngs.size}")
    var out = // big string                                                                                                                     
    rngs.forEachIndexed { i, rng -> out = out.replaceRange(rng, repl[i]) }                                                               
    return out                                                                                                                           
}
is there a better way to do this string replacement without re-assigning the string many times?