HH\Lib\C\find_key
Requires the Hack Standard Library to be installed.
Facebook Engineer?
This function is available as C\find_key()
in Facebook's www repository.
Returns the key of the first value of the given KeyedTraversable for which the predicate returns true, or null if no such value is found
namespace HH\Lib\C;
function find_key<Tk, Tv>(
KeyedTraversable<Tk, Tv> $traversable,
(function(Tv): bool) $value_predicate,
): ?Tk;
Time complexity: O(n) Space complexity: O(1)
Parameters
KeyedTraversable<Tk, Tv> $traversable
(function(Tv): bool) $value_predicate
Returns
?Tk