HH\Set::removeAll

Removes the values in the current Set that are also in the Traversable

Description

public function removeAll(
  Traversable<Tv> $other,
): Set<Tv>

If a value in the Traversable doesn't exist in the current Set, that value in the Traversable is ignored.

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

Parameters

  • $other - The Traversable containing values that will be removed from the Set.

Return Values

Examples

This example removes multiple values from a Set and shows that the list of values to be removed can contain duplicates:

<?hh

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

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

$s->removeAll(Vector {
  'red',
  'blue',
  'red',
});

var_dump($s);
Output
object(HH\Set)#1 (2) {
  string(5) "green"
  string(6) "yellow"
}