Skip to content
Justice Tech School

StringBuilder and buildString

Use StringBuilder or buildString for many appends.

Example
val s = buildString {
    for (i in 1..3) append(i).append(",")
    setLength(length - 1)
}
println(s)

Exercise

Build text.

String { append("x") }

Quiz Test

Why buildString?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.