HH\Lib\C\pop_back

Requires the Hack Standard Library to be installed.

Removes the last element from a Container and returns it

namespace HH\Lib\C;

function pop_back<T as Container<Tv>, Tv>(
  inout T $container,
): ?Tv;

If the Container is empty, null will be returned.

When an immutable Hack Collection is passed, the result will be defined by your version of hhvm and not give the expected results.

For non-empty Containers, see pop_backx.

Time complexity: O(1 or N) If the operation can happen in-place, O(1) if it must copy the Container, O(N). Space complexity: O(1 or N) If the operation can happen in-place, O(1) if it must copy the Container, O(N).

Parameters

  • inout T $container

Returns

  • ?Tv