Inspectopedia Help

String concatenation that can be converted to string template

Reports string concatenation that can be converted to a string template.

Using string templates is recommended as it makes code easier to read.

Example:

fun example() { val capitals = mapOf("France" to "Paris", "Spain" to "Madrid") for ((country, capital) in capitals) { print(capital + " is a capital of " + country) } }

After the quick-fix is applied:

fun example() { val capitals = mapOf("France" to "Paris", "Spain" to "Madrid") for ((country, capital) in capitals) { print("$capital is a capital of $country") } }

Inspection Details

Available in:

IntelliJ IDEA 2024.2, Qodana for JVM 2024.2,

Plugin:

Kotlin, @snapshot@

Last modified: 20 February 2024