HH\Lib\C\pop_frontx

Meta Engineer?

This is available as C\pop_frontx in the www repository.

Like pop_front but enforces non-empty container as input

namespace HH\Lib\C;

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

Parameters

  • inout T $container

Returns

  • Tv

Examples

$strings = vec["a", "b"];
$pop_frontx_result_1 = C\pop_frontx(inout $strings);
echo "First pop_frontx result: $pop_frontx_result_1\n";
//Output: First pop_frontx result: a

$empty_strings = vec[];
$pop_frontx_result_2 = C\pop_frontx(inout $empty_strings);
//Output: Hit a php exception : exception 'InvariantViolationException' with message
//'HH\Lib\C\pop_frontx: Expected at least one element'