HH\Map::immutable

Returns a deep, immutable copy (ImmMap) of this Map

public function immutable(): ImmMap<Tk, Tv>;

This method is interchangeable with toImmMap().

Returns

Examples

function expects_immutable(ImmMap<string, string> $iv): void {
  \var_dump($iv);
}

<<__EntryPoint>>
function basic_usage_main(): void {
  $m = Map {
    'red' => '#ff0000',
    'green' => '#00ff00',
    'blue' => '#0000ff',
    'yellow' => '#ffff00',
  };

  // Get a deep, immutable copy of $m
  $immutable_map = $m->immutable();

  expects_immutable($immutable_map);
}