W3cubDocs

/Kotlin

clear

Platform and version requirements: JS (1.3), Native (1.3)
fun StringBuilder.clear(): StringBuilder
For Common, JS

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
}
For Native

Clears the content of this string builder making it empty.

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