orElseGet

fun orElseGet(supplier: () -> T?): T?

If a value is present, returns the value, otherwise returns the result produced by the supplying function.

Return

the value, if present, otherwise the result produced by the supplying function

Parameters

supplier

the supplying function that produces a value to be returned