HH\Lib\C\onlyx

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

Returns the first and only element of the given Traversable, or throws if the Traversable is empty

namespace HH\Lib\C;

function onlyx<T>(
    Traversable<T> $traversable,
  ?HH\Lib\Str\SprintfFormatString $format_string = NULL,
  mixed ...$format_args,
): T;

An optional format string (and format arguments) may be passed to specify a custom message for the exception in the error case.

For Traversables with more than one element, see C\firstx.

Parameters