Back to Intellij Community

UnusedLambdaExpressionBody

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

2025.3-rc-2596 B
Original Source

Reports calls with an unused return value when the called function returns a lambda from an expression body.

If there is = between function header and body block, code from the function will not be evaluated which can lead to incorrect behavior.

Remove = token from function declaration can be used to amend the code automatically.

Example:

fun printHello() = { println("Hello") }

  fun main() {
      printHello() // This function doesn't print anything
  }

After the quick-fix is applied:

fun printHello() { println("Hello") }

  fun main() {
      printHello()
  }