HH\Map::clear

Remove all the elements from the current Map

Description

public function clear(): Map<Tk, Tv>;

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

Return Values

Examples

<?hh

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

$m = Map {
  'red' => '#ff0000',
  'green' => '#00ff00',
  'blue' => '#0000ff',
  'yellow' => '#ffff00',
};
var_dump($m);

$m->clear();
var_dump($m);
Output
object(HH\Map)#1 (4) {
  ["red"]=>
  string(7) "#ff0000"
  ["green"]=>
  string(7) "#00ff00"
  ["blue"]=>
  string(7) "#0000ff"
  ["yellow"]=>
  string(7) "#ffff00"
}
object(HH\Map)#1 (0) {
}