BTW, the question of whether I need parens around an if such as (if (cond) Map(dst -> src) else Map()) is always unclear to me. I usually end up putting more parens than necessary in my code.
That actually makes sense, when you think about it. What you’re describing as an “identity element” is what I think of as a “zero” in terms of a Monoid – the value of a Monoid type that you can add to any other value of that type and not change it.
(This is pretty much the rough definition of a Monoid: a type that can be “added” together, and which has a “zero” value. Map is basically a Monoid, as is List, String, Int, and lots of others. Int is really useful to think about here, because it’s a Monoid but isn’t a collection in any conventional sense.)
The thing is, when you’re looking at a List[A], or a Map[A,B], or something like that, the Monoid itself is the List or Map, not the values you put into it. And so the zero also needs to be of that collection type – it is the “empty” value of that type, like Map.empty.
++ is the operator that combines two collections, so it’s the way you can “add” the zero. +, on the other hand, isn’t really well-defined in this way: it puts something into a collection, but doesn’t combine two collections, so it doesn’t make sense as a way to add the zero of the collection.
(You can make a case that, since +is the way to combine an Int with its zero, that it should work here. Unfortunately, it doesn’t work that way on Scala collections.)