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

Change the type of set container depending on the type of key. #1728

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

volkanunsal
Copy link

@volkanunsal volkanunsal commented Aug 11, 2019

Given that the user is setting a value into a deeply nested object, when creating the container elements on the key path, the algorithm should take into consideration the type of the key. Let's take a look at how it works now:

I.setIn({}, ['a', 0], 'foo')
// => { a: { 0: 'foo' } }

The container of 'foo' is assumed to be an object, even though the key is a number. This pull request makes sure when the key is a number the container is an array or a List (if we are in an immutable object.) For example:

I.setIn({}, ['a', 0], 'foo')
// => { a: ['foo'] }

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

Successfully merging this pull request may close these issues.

None yet

1 participant