HH\Lib\Dict\merge

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

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

Merges multiple KeyedTraversables into a new dict

namespace HH\Lib\Dict;

function merge<Tk as arraykey, Tv>(
  KeyedTraversable<Tk, Tv> $first,
  KeyedContainer<Tk, Tv> ...$rest,
): dict<Tk, Tv>;

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

Time complexity: O(n + m), where n is the size of $first and m is the combined size of all the ...$rest Space complexity: O(n + m), where n is the size of $first and m is the combined size of all the ...$rest

Parameters

Returns

  • dict<Tk, Tv>