Back to Intellij Community

ReplaceToStringWithStringTemplate

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ReplaceToStringWithStringTemplate.html

2025.3-rc-2377 B
Original Source

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"
  }