nullable
Context runner that catches and normalises all non-fatal thrown exceptions into a null
value.
// Example Usage:
val a: String? = nullable { throw Exception() } // == null
val b: String? = nullable { "Hello, World!" } // == "Hello, World!"
Content copied to clipboard
Return
The result of block or null
if an exception was thrown.
Parameters
T
The return type of block.
block
The protected try-block which may throw an exception.
Context runner that catches and normalises all non-fatal thrown exceptions into a null
value.
// Example Usage:
val a: String? = 0.nullable { throw Exception() } // == null
val b: String? = 0.nullable { toString() } // == "0"
Content copied to clipboard
Return
The result of block or null
if an exception was thrown.