Requires the Hack Standard Library to be installed.
Facebook Engineer?

This function is available as Dict\take() in Facebook's www repository.

Returns a new dict containing the first $n entries of the given KeyedTraversable

namespace HH\Lib\Dict;

function take<Tk as arraykey, Tv>(
  KeyedTraversable<Tk, Tv> $traversable,
  int $n,
): dict<Tk, Tv>;

To drop the first $n entries, see Dict\drop().

Time complexity: O(n), where n is $n Space complexity: O(n), where n is $n



  • dict<Tk, Tv>