Contents

Roo

Hash.invert!

Creates a new Hash object using this Hash object’s values as keys and the keys as values. If a key with the same name already exists in the new hash then the last one encountered will be used with earlier values being discarded. The new Hash is returned and the original Hash becomes a shallow clone of the new one.

var h = {"a" => 10, "b" => 20, "c" => 30}
var i = h.invert!

print(i) # => {10 => "a", 20 => "b", 30 => "c"}
print(h) # => {10 => "a", 20 => "b", 30 => "c"}