HH\Lib\C\first

This API is part of the Hack Standard Library, not HHVM itself.

Returns the first element of the given Traversable, or null if the Traversable is empty

namespace HH\Lib\C;

function first<T>(
    Traversable<T> $traversable,
): ?T;
  • For non-empty Traversables, see C\firstx.
  • For possibly null Traversables, see C\nfirst.
  • For single-element Traversables, see C\onlyx.
  • For Awaitables that yield Traversables, see C\first_async.

Parameters