Meta Engineer?

This is available as Dict\from_entries in the www repository.

Returns a new dict where each mapping is defined by the given key/value tuples

namespace HH\Lib\Dict;

function from_entries<Tk as arraykey, Tv>(
  Traversable<(Tk, Tv)> $entries,
): dict<Tk, Tv>;

In the case of duplicate keys, later values will overwrite the previous ones.

Also known as unzip or fromItems in other implementations.

Time complexity: O(n) Space complexity: O(n)



  • dict<Tk, Tv>