[melbourne-pug] Why can't two dicts be added together?
Sam Lai
samuel.lai at gmail.com
Thu Oct 17 02:31:36 CEST 2013
It's almost Friday, so I have a question where I'm pretty sure I'm
missing something obvious.
Given,
d1 = { 'a' : 'b' }
d2 = { 'c' : 'd' }
... why isn't d3 = d1 + d2 implemented to be equivalent to -
d3 = { }
d3.update(d1)
d3.update(d2)
It doesn't work for sets either, but it works in this fashion for
lists. Is this because the operation is non-commutative for sets and
dicts and may result in a loss of data when clashing keys are
involved? Isn't that implicit when working with sets and dicts?
Sam
More information about the melbourne-pug
mailing list