W3cubDocs

/Kotlin

clear

Platform and version requirements: JS (1.3)
fun clear(): StringBuilder

Clears the content of this string builder making it empty and returns this instance.

import kotlin.test.*

fun main(args: Array<String>) {
//sampleStart
val builder = StringBuilder()
builder.append("content").append(1)
println(builder) // content1

builder.clear()
println(builder) //
//sampleEnd
}

© 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/-string-builder/clear.html