Shorter/clearer way of extracting common and unique elements from a map

OK.
The only check is from first map to the second, I mean, we only check if a element is in map first and not in the second, but the opposite is not done.
Just add the following code before returning maps in the unique function

// Now search for elements only in second mao and not in first map
	for key, value := range second {
	   if _, ok := first[key]; !ok {
	     uniqueMap[key] = value
	   }
	}
	
	return commonMap, uniqueMap
3 Likes