Mark unused parameters in Kotlin

With the @Suppress annotation You can suppress any diagnostics on any declaration or expression.

Examples: Suppress warning on parameter:

fun foo(a: Int, @Suppress("UNUSED_PARAMETER") b: Int) = a

Suppress all UNUSED_PARAMETER warnings inside declaration

@Suppress("UNUSED_PARAMETER")
fun foo(a: Int,  b: Int) {
  fun bar(c: Int) {}
}

@Suppress("UNUSED_PARAMETER")
class Baz {
    fun foo(a: Int,  b: Int) {
        fun bar(c: Int) {}
    }
}

Additionally IDEA's intentions(Alt+Enter) can help you to suppress any diagnostics:


If your parameter is in a lambda, you can use an underscore to omit it. This removes the unused parameter warnings. It will also prevent IllegalArgumentException in the case that the parameter was null and was marked non-null.

See https://kotlinlang.org/docs/reference/lambdas.html#underscore-for-unused-variables-since-11