3 ms·
How does {1:"A"}+{} = {1:"A"} imply that {} is no longer a zero value? 1+0=1 makes total sense...
by aiiane 13y ago
How does {1:"A"}+{} = {1:"A"} imply that {} is no longer a zero value? 1+0=1 makes total sense...
- dalke 13y agoIt's not just that one expression, but when done in addition to the previous suggested answer. That is, what is the type of the values in the summed dictionaries? If {1:"A"}+{} == {1:"A"} then the type of each value is unchanged from the input list. If {1:"A"}+{1:"B"} == {1:["A","B"]} then the type of each value (or at least each shared value) is a 2-element list. If both are true, then no one can write sane code which knows how deal with the sum of two dictionaries. That is, the insane code has to have checks for if one of the dictionaries is empty, and if so, do one thing, otherwise do another thing. In which case, why is this definition useful? Therefore, either {} is the zero value, or dictionary summation produces lists for the resulting values, but not both.
- anamexis 13y agoIn the comment above, the hypothetical result is {1:["A"]}, not {1:"A"}. (The value is in a list.)