HH\Pair::skip

Returns an ImmVector containing the values after the n-th element of the current Pair.

Description

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

Returns an ImmVector containing the values after the n-th element of the current Pair.

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

Parameters

  • int $n - The last element to be skipped; the $n+1 element will be the first one in the returned ImmVector.

Return Values

Examples

<?hh

namespace Hack\UserDocumentation\API\Examples\Pair\Skip;

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

// Skipping 0 returns an ImmVector of both values
var_dump($p->skip(0));

// Skipping 1 returns an ImmVector of the second value
var_dump($p->skip(1));

// Skipping more than 1 returns an empty ImmVector
var_dump($p->skip(2));
Output
object(HH\ImmVector)#2 (2) {
  [0]=>
  string(3) "foo"
  [1]=>
  float(-1.5)
}
object(HH\ImmVector)#2 (1) {
  [0]=>
  float(-1.5)
}
object(HH\ImmVector)#2 (0) {
}