Hyperlinkv0.8.0-beta.28

Tuple

Tuple.getconsteffect/Tuple.ts:76
<const T extends ReadonlyArray<unknown>, I extends Indices<T> & keyof T>(
  index: I
): (self: T) => T[I]
<const T extends ReadonlyArray<unknown>, I extends Indices<T> & keyof T>(
  self: T,
  index: I
): T[I]

Retrieves the element at the specified index from a tuple.

When to use

Use when a single tuple element should be extracted in a pipeline.

Details

The index is constrained to valid tuple positions at the type level.

Example (Extracting an element by index)

import { pipe, Tuple } from "effect"

const last = pipe(Tuple.make(1, true, "hello"), Tuple.get(2))
console.log(last) // "hello"
gettersmakepick
Source effect/Tuple.ts:764 lines
export const get: {
  <const T extends ReadonlyArray<unknown>, I extends Indices<T> & keyof T>(index: I): (self: T) => T[I]
  <const T extends ReadonlyArray<unknown>, I extends Indices<T> & keyof T>(self: T, index: I): T[I]
} = dual(2, <T extends ReadonlyArray<unknown>, I extends keyof T>(self: T, index: I): T[I] => self[index])