@NonNull open static fun <R : Any!> of(@NonNull supplier: Supplier<out R>): Try<R>
Creates a Try
from a given Supplier
. The code run by the supplier can throw an RuntimeException
, this exception will be caught and wrapped by the resulting Try.
supplier
- Supplier<out R>: creates a value that will be wrapped in Try.
- type of the value returned by the Supplier
Return
Try<R>: Success
if a value is returned from the given Supplier
, Failure
otherwise.