onrails
    Preparing search index...
    • Start a pattern-matching expression. Two call shapes:

      • match(value) — data-first; subsequent .exhaustive() or .otherwise(fn) runs immediately against value.
      • match<T>() — curried; subsequent .exhaustive() returns a function (value: T) => R for use in pipe(...) or as a reusable matcher.

      Type Parameters

      • T

      Parameters

      • input: T

      Returns MatchBuilder<T, never, true>

      // Data-first
      const out = match({ kind: "click", x: 1, y: 2 } as Event)
      .with({ kind: "click" }, (e) => e.x + e.y)
      .with({ kind: "key" }, () => -1)
      .exhaustive();

      // Curried — build a reusable matcher
      const describe = match<Event>()
      .with({ kind: "click" }, (e) => `click @ ${e.x},${e.y}`)
      .with({ kind: "key" }, (e) => `key ${e.code}`)
      .exhaustive();
    • Start a pattern-matching expression. Two call shapes:

      • match(value) — data-first; subsequent .exhaustive() or .otherwise(fn) runs immediately against value.
      • match<T>() — curried; subsequent .exhaustive() returns a function (value: T) => R for use in pipe(...) or as a reusable matcher.

      Type Parameters

      • T = never

      Returns MatchBuilder<T, never, false>

      // Data-first
      const out = match({ kind: "click", x: 1, y: 2 } as Event)
      .with({ kind: "click" }, (e) => e.x + e.y)
      .with({ kind: "key" }, () => -1)
      .exhaustive();

      // Curried — build a reusable matcher
      const describe = match<Event>()
      .with({ kind: "click" }, (e) => `click @ ${e.x},${e.y}`)
      .with({ kind: "key" }, (e) => `key ${e.code}`)
      .exhaustive();