Skip to main content

concat

Note

This is a point-in-time snapshot of the API documentation from January 2026. Going forward, we will not be maintaining a public copy of these references, and recommend users to refer to the built-in signature helpers available in the Hack LSP instead for complete and up-to-date information.

Returns a Vector that is the concatenation of the values of the current Set and the values of the provided Traversable

public function concat<Tu super Tv>(
Traversable<Tu> $traversable,
): Vector<Tu>;

The values of the provided Traversable is concatenated to the end of the current Set to produce the returned Vector.

Guide

Parameters

Returns

Examples

This example creates new Sets by concatenating other Traversables. Unlike Set::addAll() this method returns a new Set (not a shallow copy).

$s = Set {'red'};

// Add all the values in a Vector
$s1 = $s->concat(Vector {'green', 'blue'});

// Add all the values in an array
$s2 = $s1->concat(varray['yellow', 'purple']);

\var_dump($s); // $s contains 'red'
\var_dump($s1); // $s1 contains 'red', 'green', 'blue'
\var_dump($s2); // $s2 contains 'red', 'green', 'blue', 'yellow', 'purple'