Attempt
Last updated
Was this helpful?
Was this helpful?
attempt = attempt( () => 10 / 2 );
writeOutput( attempt.get() );
attempt = attempt( () => 10 / 0 );
writeOutput( attempt.hasError() );
result = attempt( () => "hello".len() )
.map( (x) => x * 2 )
.getOrDefault( 0 );
writeOutput( result );
attempt = attempt();
writeOutput( attempt.isEmpty() );