restrictLengthWithEllipsis

fun String.restrictLengthWithEllipsis(maxLength: Int, ellipsis: String = "…"): String

Shortens the string to maxLength; in such case, appends the ellipsis (typically "…" ).

For example, returns "ABCD…" when called for "ABCDEFHG".(5, "…")

Sources

Katlib source
Link copied to clipboard