merge
Note
This is a point-in-time snapshot of the API documentation from January 2026. Going forward, we will not be maintaining a public copy of these references, and recommend users to refer to the built-in signature helpers available in the Hack LSP instead for complete and up-to-date information.
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
KeyedTraversable<Tk,Tv> $firstKeyedContainer<Tk,Tv> ...$rest