Version: v0.6.0 - Beta.  We welcome contributors & feedback.  THanks!

Map.reverse

reverse()

Description

Flip each key/value pair so that the values is the key, and the key is the value.

If duplicate keys are created, the latest one will overwrite all previous keys.

$map = { a: 1, b: 2, c: 1 };
$flippedMap = $map.reverse();

print($flippedMap);
//= { 1: 'c', 2: 'b' }