truncate

fun String.truncate(maxLength: Int, ellipsis: String = "..."): String(source)

Truncates a String to maxLength characters, appending ellipsis if truncated. Example: "Hello, World!".truncate(8) → "Hello..."