Hyperlinkv0.8.0-beta.28

Array

Array.dropconsteffect/Array.ts:1508
(n: number): <A>(self: Iterable<A>) => Array<A>
<A>(self: Iterable<A>, n: number): Array<A>

Removes the first n elements, creating a new array.

When to use

Use to keep the suffix of an iterable after skipping a fixed number of leading elements.

Details

n is clamped to [0, length]. When n <= 0, this returns a copy of the full array.

Example (Dropping from the start)

import { Array } from "effect"

console.log(Array.drop([1, 2, 3, 4, 5], 2)) // [3, 4, 5]
Source effect/Array.ts:15087 lines
export const drop: {
  (n: number): <A>(self: Iterable<A>) => Array<A>
  <A>(self: Iterable<A>, n: number): Array<A>
} = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {
  const input = fromIterable(self)
  return input.slice(clamp(n, input), input.length)
})