This API is part of the Hack Standard Library, not HHVM itself.

Returns a new vec containing the subsequence of the given Traversable determined by the offset and length

namespace HH\Lib\Vec;

function slice<Tv>(
  Container<Tv> $container,
  int $offset,
  ?int $length = null,
): vec<Tv>;

If no length is given or it exceeds the upper bound of the Traversable, the vec will contain every element after the offset.

  • To take only the first $n elements, see Vec\take().
  • To drop the first $n elements, see Vec\drop().