HH\Set::clear

Remove all the elements from the current Set.

Description

public function clear(): Set<Tv>

Remove all the elements from the current Set.

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

Return Values

  • Set<Tv> - A shallow, empty copy of the current Set. The current Set is also empty.

Examples

<?hh

namespace Hack\UserDocumentation\API\Examples\Set\Clear;

$s = Set {'red', 'green', 'blue', 'yellow'};
var_dump($s);

$s->clear();
var_dump($s);
Output
object(HH\Set)#1 (4) {
  string(3) "red"
  string(5) "green"
  string(4) "blue"
  string(6) "yellow"
}
object(HH\Set)#1 (0) {
}