Hyperlinkv0.8.0-beta.28

Option

Option.getOrUndefinedconsteffect/Option.ts:1009
<A>(self: Option<A>): A | undefined

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

When to use

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

Details

  • Some → the inner value
  • Noneundefined

Example (Unwrapping to undefined)

import { Option } from "effect"

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

console.log(Option.getOrUndefined(Option.none()))
// Output: undefined
Source effect/Option.ts:10091 lines
export const getOrUndefined: <A>(self: Option<A>) => A | undefined = getOrElse(constUndefined)
Referenced by 5 symbols