For the complete documentation index, see llms.txt. This page is also available as Markdown.

Attempt

Create an Attempt object with or without a given value so you can do fluent operations on the registered attempt value.

Method Signature

Attempt(value=[any])

Arguments

Argument
Type
Required
Description
Default

value

any

false

The value to store as the attempt. This can be a value, or a closure/lambda that will be executed to get the value.

Examples

Create an Attempt with a value

Wraps a value in an Attempt object for fluent error-safe operations.

attempt = attempt( 42 );
writeOutput( attempt.get() );

Result: 42

Create an Attempt with a closure

The closure is executed and its result (or exception) is captured.

Result: 5

Attempt that catches an exception

When the closure throws, the Attempt captures the failure instead of crashing.

Result: true

Fluent chaining with Attempt

Result: 10

Attempt with no value

Creates an empty Attempt object for later use.

Result: true

Last updated

Was this helpful?