on

inline fun <Parent, Child : Any> Parent.on(instanceof: KClass<Child>, block: Child.() -> Unit): Parent

Executes the block if the Parent is an instance of type Child.

// Chained function call alternative to:
receiver.also { if(this is Child) block(this) }

// Example usage:
receiver.on(Child::class) { ... }

Return

The original Parent object.

Parameters

instanceof

The KClass of the Child type.

block

The lambda to execute if the Parent is an instance of type Child.