<Kotlin - Why can't I pass this method directly in...
# stackoverflow
u
Kotlin - Why can't I pass this method directly into the constructor, why do I need to use a lambda? I just started to learn Kotlin yesterday, so brace yourself for a potentially stupid question. class MyCustomViewAdapter(private val callback: (position: Int) -> Unit) : RecyclerView.Adapter() { ... } When I try to initialize this class, I need to pass in a callback parameter to receive events. MyCustomViewAdapter({ position -> onClickFlowerCallback(position)}) // this works MyCustomViewAdapter(onClickFlowerCallback) // this doesn't work? private fun onClickFlowerCallback(position:...