HH\Vector::toImmMap

Description

public function toImmMap(): ImmMap<int,Tv>

Returns an immutable, integer-keyed map (ImmMap) based on the values of the current Vector.

Return Values

Examples

<?hh

namespace Hack\UserDocumentation\API\Examples\Vector\ToImmMap;

$v = Vector {'red', 'green', 'blue', 'yellow'};

$imm_map = $v->toImmMap();

var_dump($imm_map instanceof \HH\ImmMap);
var_dump($imm_map->keys());
var_dump($imm_map);
Output
bool(true)
object(HH\ImmVector)#3 (4) {
  [0]=>
  int(0)
  [1]=>
  int(1)
  [2]=>
  int(2)
  [3]=>
  int(3)
}
object(HH\ImmMap)#2 (4) {
  [0]=>
  string(3) "red"
  [1]=>
  string(5) "green"
  [2]=>
  string(4) "blue"
  [3]=>
  string(6) "yellow"
}