-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mergeIn bug? #597
Comments
Could you add what you expected in this case? I can explain what is happening at present: "merge" is an operation you perform upon a collection, but the value found at [2,"c"] is undefined. Perhaps we could improve the behavior or at least the error message in this case, but I'm curious what you expected the outcome to be if not an error. |
Maybe @ddaza is confused about merging [1,2,3,4,5] and [5,6,7] results in [5,6,7,4,5] and not [1,2,3,4,5,6,7]? |
Sorry i didn't specify where the confusion is. The last line of the test is what I find inconsistent. When I merge 2 objects and keys I assumed that the keys will remain and values are swapped by the new merged object, since the documentation says that MergeIn is "A combination of updateIn and merge". In my opinion that logic should make If the current functionality is done by design then is my mistake. Thanks! |
Ah, I understand. At present, the operation you're attempting is covered by |
So these two variants should behave as you expect: mergeIn against something collection-like: test.mergeIn([2], { c: 'hello' }) setIn when wanting to position a value regardless of mergeability test.setIn([2, 'c'], 'hello') |
thanks |
I disagree that this is expected behavior. Null is not formally a value, but is typically used as a de facto value in JSON, so that the key is held open for further updates. When I have a data structure that can change shape and value over successive generations of So what are the alternatives? First, I can use But going back to the problem of a structure that adds keys. If I use So I throw my hands in the air and use To me, this defeats the purpose of high-level convenience functions, which is to be convenient without surprising corner cases. If the behavior is not intended to change, perhaps a more helpful error message could be added? Something of the form
|
Update for anyone foolish enough to take me seriously, I got the above only partly halfway correct.
|
is this a bug?
I find it a little inconsistent from what i was expecting to happen.
The text was updated successfully, but these errors were encountered: