HH\Vector::add

Appends a value to the end of the current Vector, assigning it the next available integer key

public function add(
  Tv $value,
): Vector<Tv>;

If you want to overwrite the value for an existing key, use set().

$vec->add($v) is semantically equivalent to $vec[] = $v (except that add() returns the current Vector).

Future changes made to the current Vector ARE reflected in the returned Vector, and vice-versa.

If $v is an object, future changes to the added element ARE reflected in $v, and vice versa.

Parameters

  • Tv $value

Return Values