Reusing anko coroutines


#1

Hello,
I would like to reuse code for the onClick invocation. For example:

holder.cost.onClick {
    print something...
}

Instead do something like

val myCode = {print something ...}
holder.cost.onClick = myCode

It does not work, instead I’m using

val myCode = {print something ...}
holder.cost.onClick = {
    myCode.invoke()
}

Ideas would be appreciated


#2

holder.cost.onClick(::myCode)