takeOrCut

fun String.takeOrCut(n: Int, countDots: Boolean = true): String

Returns a string containing the first n characters from this string + 3-bytes character , or the entire string if the string is shorter.

Example:

"Hello world".takeOrCut(6) // "Hello…"
"Hello world".takeOrCut(5, countDots = false) // "Hello…"

Parameters

countDots

if true and string longer than n, result string's length with included will be n length, otherwise n length + 1

Throws