The stripTrailing() Function is used to remove any unwanted character from the right side of the String with Space by default.
fun main() { var x = " Hello " var y = x.stripTrailing() println(y+"World") }
In the above code, we have declared a String ' Hello ' with leading and trailing spaces.
Then we have used the 'stripTrailing()' function to remove the unwanted spaces from right side only.
So, the unwanted spaces are stripped out from the right side of the String.