A very basic question, what is the right way to concatenate a String in Kotlin?
In Java you would use the concat() method, e.g.
String a
In Kotlin, you can concatenate using string interpolation / templates:
val a = "Hello"
val b = "World"
val c = "$a $b"
The output will be: Hello World
Or you can concatenate using the + / plus() operator:
val a = "Hello"
val b = "World"
val c = a + b // same as calling operator function a.plus(b)
print(c)
The output will be: HelloWorld
Or you can concatenate using the StringBuilder.
val a = "Hello"
val b = "World"
val sb = StringBuilder()
sb.append(a).append(b)
val c = sb.toString()
print(c)
The output will be: HelloWorld