I want to trim a string if the length exceeds 10 characters.
Suppose if the string length is 12 (String s=\"abcdafghijkl\"), then the new trimmed string
String s=\"abcdafghijkl\"
Here is the Kotlin solution
One line,
if (yourString?.length!! >= 10) yourString?.take(90).plus("...") else yourString
Traditional,
if (yourString?.length!! >= 10) { yourString?.take(10).plus("...") } else { yourString }