dropLast

Returns a subsequence of this char sequence with the last n characters removed.

fun CharSequence.dropLast(n: Int): CharSequence(source)
val text = "Hello, World!"
val shortened = text.dropLast(6)   // "Hello, "
println(shortened)

Source