I have a function like this: `override fun process...
# announcements
k
I have a function like this:
override fun processNewLines(lines: Array<String>) = lines.forEach { <http://logger.info|logger.info>(it) }
and it works as expected however when I change last invocation to lambda:
override fun processNewLines(lines: Array<String>) = lines.forEach { logger::info }
code compiles fine but there is a runtime error
java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReference.<init>(ILjava/lang/Object;)V
at that line
k
koral: It should be
lines.forEach(logger::info)
. Notice the paren instead of a curly brace.
logger::info
itself is a function reference, so no need to wrap it inside a lambda
k
👌 thanks