Re:Map.merge() – One method to rule them all
by kazinator on Sunday March 31, 2019 @11:59AM
(#19536252)
This is a poor semantics. The function should always be called. In the non-existent-key case, it should be invoked on the default value that is supplied. Thus the example of the histogram tabulation would use 0 as the initial value.
The name is ill-chosen; this mutator doesn't "merge" at all; it "updates" the map entry through a function, with a default value.
"merge" might be a somewhat good name for an operation that combines two maps, with a function that resolves key clashes; though since that is a kind of set union, that provides better terminology.
The name is ill-chosen; this mutator doesn't "merge" at all; it "updates" the map entry through a function, with a default value.
"merge" might be a somewhat good name for an operation that combines two maps, with a function that resolves key clashes; though since that is a kind of set union, that provides better terminology.