hey, how can I trim last 4 or 5 characters from st...
# announcements
s
hey, how can I trim last 4 or 5 characters from string using collection functions?
d
What exactly do you mean by "collection functions"? If you want to remove the last 4 characters of a String,
substring
is what you want:
Copy code
val s = "Hello World"
s.substring(0, s.length - 5)
m
You can use `dropLast`:
"Hello World!".dropLast(5)
👍 3
g
also maybe it’s a good question for #getting-started
s
thanks.