Take

public struct Take: Fn

Take returns a new Collection or Page that contains num elements from the head of the Collection or Page coll. If take value is zero or negative, the resulting collection is empty. When applied to a page, the returned page’s after cursor is adjusted to only cover the taken elements.

As special cases:

  • If take value is negative, after will be set to the same value as the original page’s before.
  • If all elements from the original page were taken, after does not change.

Reference.

  • Declaration

    Swift

    public init(count: Expr, from collection: Expr)

    Parameters

    count

    Number of items to be taken.

    collection

    Collection or page.