Kotlin: how to swap character in String
<p>I would like to swap a string from "abcde" to "bcdea". So I wrote my code as below in Kotlin</p>

<pre><code>var prevResult = "abcde"
var tmp = prevResult[0]

for (i in 0..prevResult.length - 2) {
    prevResult[i] = prevResult[i+1]  // Error on preveResult[i]
}

prevResult[prevResult.length-1] = tmp // Error on preveResult[prevResult.lengt-1]
</code></pre>

<p>It errors out as stated above comment line. What did I do wrong? How could I fix this and get what I want?</p>