Hyperlinkv0.8.0-beta.28

Option

Option.isSomeconsteffect/Option.ts:388
<A>(self: Option<A>): self is Some<A>

Checks whether an Option contains a value (Some).

When to use

Use when you need to branch on a present Option before accessing .value.

Details

  • Acts as a type guard, narrowing to Some<A>

Example (Checking for Some)

import { Option } from "effect"

console.log(Option.isSome(Option.some(1)))
// Output: true

console.log(Option.isSome(Option.none()))
// Output: false
guardsisNone
Source effect/Option.ts:3881 lines
export const isSome: <A>(self: Option<A>) => self is Some<A> = option.isSome
Referenced by 50 symbols