objects.merge does not overwrite when value is a list
bimalkant-lauhny opened this issue · comments
The objects.merge docs say
Subsequent sources will overwrite property assignments of previous sources.
If I understand it correctly, it should overwrite
the properties in first argument with the ones in second argument. But it instead works like this
>>> _.merge({'a': [1 , 2, 3]}, {'a': [4]})
{'a': [4, 2, 3]}
Not sure if this is intentional, but I suppose it should've worked something like this 🤔
>>> _.merge({'a': [1 , 2, 3]}, {'a': [4]})
{'a': [4]}
I'm using pydash 4.9.1
with Python 3.8.5
Update on this,
Seems like it treats even a list as a dictionary where list indices act as dict keys and list values act as dict values.
This can be further confirmed as follows
>>> _.merge({'a': 1, 'b': 2}, [3, 4])
{'a': 1, 'b': 2, 0: 3, 1: 4}
Now the only question is, is this intentional? 🤔
Oh okay I get it. It works exactly like lodash merge. Closing this!