Hyperlinkv0.8.0-beta.28

Option

Option.getOrNullconsteffect/Option.ts:976
<A>(self: Option<A>): A | null

Extracts the value from a Some, or returns null for None.

When to use

Use when you need to pass absent Option values to APIs that expect null.

Details

  • Some → the inner value
  • Nonenull

Example (Unwrapping to null)

import { Option } from "effect"

console.log(Option.getOrNull(Option.some(1)))
// Output: 1

console.log(Option.getOrNull(Option.none()))
// Output: null
Source effect/Option.ts:9761 lines
export const getOrNull: <A>(self: Option<A>) => A | null = getOrElse(constNull)
Referenced by 2 symbols