fun CharSequence.repeat(n: Int): String
Returns a string containing this char sequence repeated n times.
import kotlin.test.*
fun main(args: Array<String>) {
//sampleStart
println("Word".repeat(4)) // WordWordWordWord
println("Word".repeat(0)) //
//sampleEnd
}
IllegalArgumentException
- when n < 0.
Returns a string containing this char sequence repeated n times.
IllegalArgumentException
- when n < 0.
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/repeat.html