Working with Text
7 min · Kotlin
Join strings, measure them, and use Kotlin string templates.
Kotlin · Working with Text0/5 cleared
Enemy 1 of 5
Text in Kotlin is stored as a String value, written between double quotes. You can join two strings together with the + operator, the same way you'd combine numbers with addition — Kotlin overloads + so it means concatenation (joining) when both sides are strings.
This works even when mixing a String with other types in some cases (like a String plus a number), because Kotlin will convert the other value to text automatically. Still, using + repeatedly to build up a sentence from many pieces gets clunky fast, which is exactly the problem the next section's string templates solve.
You
Packet Wolf
Loading editor...
Ln 1, Col 1Spaces: 4
Sign up to fightTarget output: Hello, Ada