.dropRight
instead of .substring
when the lower-bound is 0 SC-R1027String.dropRight
provides a convenient way to remove an n
character suffix from a string. Consider rewriting .substring(0, ub)
as .dropRight(n)
; this is more succinct and clear.
val substr = str.substring(0, n - 3)
val substr = str.dropRight(3)