Package: effect
Module: Option
Pattern-matches on an Option, handling both None and Some cases.
When to use
Use when you need to handle both Some and None in one expression and
transform an Option into a plain value.
Details
None, calls onNone and returns its resultSome, calls onSome with the value and returns its resultdual API (data-last and data-first)Example (Matching on an Option)
import { Option } from "effect"
const message = Option.match(Option.some(1), {
onNone: () => "Option is empty",
onSome: (value) => `Option has a value: ${value}`
})
console.log(message)
// Output: "Option has a value: 1"
See
getOrElse for unwrapping with a defaultSignature
declare const match: { <B, A, C = B>(options: { readonly onNone: LazyArg<B>; readonly onSome: (a: A) => C; }): (self: Option<A>) => B | C; <A, B, C = B>(self: Option<A>, options: { readonly onNone: LazyArg<B>; readonly onSome: (a: A) => C; }): B | C; }
Since v2.0.0