For Kotlin dudes ;) from the accepted answer (@MikeThomsen's)
fun String.insert(index: Int, string: String): String {
return this.substring(0, index) + string + this.substring(index, this.length)
}
Test ?
"ThisTest".insert(4, "Is").should.equal("ThisIsTest")