maxmello
11/02/2021, 4:56 PMjoinToString
has truncated: CharSequence = "..."
as an optional parameter. It would be nice if String.take(n: Int)
could have the same optional parameter that is appended in case n
is smaller than the length of the String. Maybe it could also be a different method name, as this would be more a use case for logging/displaying a string similar to joinToString, rather than “working on a string” by using substring for maybe some logical operation on the string. It could be something like abbreviate
or maybe cut
arekolek
11/02/2021, 5:04 PM"foo bar".take(7, truncated="...") == "foo bar"
"foo bar".take(6, truncated="...") == "foo ba..."
or
"foo bar".take(7, truncated="...") == "foo ..."
"foo bar".take(6, truncated="...") == "foo..."
?maxmello
11/02/2021, 5:15 PMtruncatedAppend
or so