Back to Intellij Community

RemoveToStringInStringTemplate

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

2025.3-rc-2368 B
Original Source

Reports calls to toString() in string templates that can be safely removed.

Example:

fun foo(a: Int, b: Int) = a + b

  fun test(): String {
      return "Foo: ${foo(0, 4).toString()}" // 'toString()' is redundant
  }

After the quick-fix is applied:

fun foo(a: Int, b: Int) = a + b

  fun test(): String {
      return "Foo: ${foo(0, 4)}"
  }