September 2017
Intermediate to advanced
216 pages
6h 8m
English
Maps can have more complex values as keys, which means that you could have a trickier situation to deal with when there are merge conflicts. Let's reuse our previous example and change the keys into something more involved:
const myMap1 = Map.of( Map.of('name', 'one'), 1, Map.of('name', 'two'), 2, Map.of('name', 'three'), 3);const myMap2 = Map.of( Map.of('name', 'two'), 22, Map.of('name', 'three'), 33, Map.of('name', 'four'), 4);const myMergedMap = myMap1.merge(myMap2);const myMergedWith = myMap1.mergeWith( v => v, myMap2);console.log('myMap1', myMap1.toJS());// -> myMap1 { 'Map { "name": "one" }': 1,// -> 'Map { "name": "two" }': 2,// -> 'Map { "name": "three" }': 3 }console.log('myMap2', myMap2.toJS());// ...Read now
Unlock full access