HH\Vector::skip

Returns a Vector containing the values after the n-th element of the current Vector.

Description

public function skip(
  int $n,
): Vector<Tv>

Returns a Vector containing the values after the n-th element of the current Vector.

The returned Vector will always be a proper subset of the current Vector.

n is 1-based. So the first element is 1, the second 2, etc.

Parameters

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

Return Values

  • Vector<Tv> - A Vector that is a proper subset of the current Vector containing values after the specified n-th element.

Examples

<?hh

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

$v = Vector {'red', 'green', 'blue', 'yellow'};

// Create a new Vector after skipping the first two elements ('red' and 'green')
$skip2 = $v->skip(2);

var_dump($skip2);
Output
object(HH\Vector)#2 (2) {
  [0]=>
  string(4) "blue"
  [1]=>
  string(6) "yellow"
}