repeat string n times in Kotlin
The built in CharSequence.repeat extension does this in an efficient way, see the source here. val str: String = “*”.repeat(100) Of course, this will still require O(n) steps to create the string. However, using this built-in stdlib function has its advantages: it’s cross-platform, easy to read, and can be improved in performance over time, if …