-
Notifications
You must be signed in to change notification settings - Fork 0
swap
Subhajit Sahu edited this page Jun 17, 2020
·
14 revisions
Exchanges two values. 🏃 📼 📦 🌔 📒
entries.swap(x, k, l);
// x: entries
// k: a key
// l: another key
const map = require('extra-map');
var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4]]);
map.swap(x, 'a', 'b');
// Map(4) { 'a' => 2, 'b' => 1, 'c' => 3, 'd' => 4 }
map.swap(x, 'a', 'd');
// Map(4) { 'a' => 4, 'b' => 2, 'c' => 3, 'd' => 1 }