Skip to content
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

setIn doesn't always create arrays for numeric keys #7

Closed
adierkens opened this issue Mar 3, 2017 · 2 comments
Closed

setIn doesn't always create arrays for numeric keys #7

adierkens opened this issue Mar 3, 2017 · 2 comments

Comments

@adierkens
Copy link
Contributor

I've noticed some discrepancies when using numeric keys w/ setIn

Consider the following:

setIn(undefined, ['x', 0, 'y'], true)
// { x: { '0': { y: true } } }

setIn({}, ['x', 0, 'y'], true)
// { x: [ { y: true } ] }

I would expect both examples to result in the same outcome, but for some reason it decided to use 0 as a key for a new object, rather than an index in an array.

There are other use cases with similar outcomes:

setIn(undefined, [0, 'y', 'z'], true)
// [ { y: { z: true } } ]

setIn(undefined, ['x', 0, 'y', 'z'], true)
// { x: { '0': { y: { z: true} } } }

Again, I would expect the second to produce an array, rather than an object.

@guigrpa
Copy link
Owner

guigrpa commented Mar 4, 2017

Thanks for the report and PR! Released in v1.2.4

@adierkens
Copy link
Contributor Author

Thanks for the quick release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants