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 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023