HH\Lib\C\find

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

This function is available as C\find() in Facebook's www repository.

Returns the first value of the given Traversable for which the predicate returns true, or null if no such value is found

namespace HH\Lib\C;

function find<T>(
  Traversable<T> $traversable,
  (function(T): bool) $value_predicate,
): ?T;

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

Parameters

Returns

  • ?T