HH\Set::toSet
Returns a deep copy of the current Set
public function toSet(): Set<Tv>;
Returns
Set<Tv>
- aSet
that is a deep copy of the currentSet
.
Examples
This example shows that toSet
returns a deep copy of the Set
:
$s = Set {'red', 'green', 'blue', 'yellow'};
// Make a deep copy of Set $s
$s2 = $s->toSet();
// Modify $s2 by adding an element
$s2->add('purple');
\var_dump($s2);
// The original Set $s doesn't include 'purple'
\var_dump($s);