HH\Vector::resize
Resize the current Vector
public function resize(
int $size,
Tv $value,
): void;
Resize the current Vector to contain $sz elements. If $sz is smaller
than the current size of the current Vector, elements are removed from
the end of the current Vector. If $sz is greater than the current size
of the current Vector, the current Vector is extended by appending as
many copies of $value as needed to reach a size of $sz elements.
$value can be null.
If $sz is less than zero, an exception is thrown.
Parameters
int $sizeTv $value- The value to use as the filler if we are increasing the size of the currentVector.
Returns
void
Examples
This example shows how resize can be used to decrease and increase the size of a Vector:
$v = Vector {'red', 'green', 'blue', 'yellow'};
// Resize the Vector to 2 (removing 'blue' and 'yellow')
$v->resize(2, null);
\var_dump($v);
// Resize the Vector back to 4 (filling in 'unknown' for new elements)
$v->resize(4, 'unknown');
\var_dump($v);