Inspectopedia Help

Call of 'toString' could be replaced with string template

Reports toString function calls that can be replaced with a string template.

Using string templates makes your code simpler.

The quick-fix replaces toString with a string template.

Example:

fun test(): String { val x = 1 return x.toString() }

After the quick-fix is applied:

fun test(): String { val x = 1 return "$x" }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023