tryOrNull
Runs block and returns its value, or null when it throws an Exception.
Only Exception is caught, not Throwable, so Errors and other non-Exception throwables propagate to the caller. This function is not suspending: CancellationException is an Exception and would be swallowed here, so do not wrap suspending calls in it. Suspend-aware variants exist elsewhere in this library as runCatchingCancellable.
val parsed: Int? = tryOrNull { text.toInt() }Content copied to clipboard
Return
Parameters
block
computation to attempt.