Returns an ImmVector containing the first n values of the current Pair

public function take(
  int $n,
): ImmVector<mixed>;

n is 1-based. So the first element is 1, the second 2. There is no element 3 in a Pair, but if you specify an element greater than 2, it will just return all elements in the Pair.


  • int $n - The last element that will be included in the current Pair.



$p = Pair {'foo', -1.5};

// Taking 0 returns an empty ImmVector

// Taking 1 returns an ImmVector of the first value

// Taking 2 (or more) returns an ImmVector containing both values