Q:

Kotlin - How to correctly concatenate a String

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 = "Hello ";
String b = a.concat("World"); // b = Hello World

The concat() function isn't available for Kotlin though. Should I use the + sign?

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

A:

kotlin.String has a plus method:
a.plus(b)

See https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/plus.html for details.

A:

Yes, you can concatenate using a + sign. Kotlin has string templates, so it's better to use them like:
var fn = "Hello"
var ln = "World"

"$fn $ln" for concatenation. 
You can even use String.plus() method.

