String Trim in Kotlin
Level 270 keystrokes
Removes leading and trailing whitespace from a string with trim().
Kotlin code
// Two spaces at each end; the total length is 151val text = " hello world "// trim() returns a new string without the outer whitespace: hello world2println(text.trim())// text itself is unchanged, so its length is still 153println(text.length)Output
hello world 15
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Kotlin code and how often they appear.
(× 3)× 3.× 2"× 2=× 1