on Is Null
Executes the given block only if this object is null.
This inline function provides a concise way to perform an action when a nullable object is null, acting as a syntactic sugar for a standard if (this == null) { ... } check.
Example:
var user: User? = null
user.onIsNull {
println("User is not initialized.")
}
// Output: User is not initialized.
user = User("John")
user.onIsNull {
println("This will not be printed.")
}
// No outputContent copied to clipboard
Parameters
block
The lambda function to be executed if the object is null.