Since you can't reference a lambda you're currently in, and you can't reference the property you're defining while you're defining the lambda you're assigning to it, the best solution here is an object
expression:
val runnableCode = object: Runnable {
override fun run() {
handler.postDelayed(this, 5000)
}
}
Assuming that this property is not a var
because you actually want to change it while this self-calling is happening.