map_with_key
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.
Returns a new vec where each value is the result of calling the given function on the original key and value
namespace HH\Lib\Vec;
function map_with_key<Tk, Tv1, Tv2>(
KeyedTraversable<Tk, Tv1> $traversable,
(function(Tk, Tv1): Tv2) $value_func,
): vec<Tv2>;
Time complexity: O(n * f), where f is the complexity of $value_func
Space complexity: O(n)
Parameters
KeyedTraversable<Tk,Tv1> $traversable(function(Tk, Tv1): Tv2) $value_func
Returns
vec<Tv2>