effect-io-ai

Package: effect
Module: Option

Option.toArray

Converts an Option into an Array.

When to use

Use when you need to pass an Option to array-based APIs or spread optional values into collections.

Details

Example (Converting to an array)

import { Option } from "effect"

console.log(Option.toArray(Option.some(1)))
// Output: [1]

console.log(Option.toArray(Option.none()))
// Output: []

See

Signature

declare const toArray: <A>(self: Option<A>) => Array<A>

Source

Since v2.0.0