Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

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'] }

@jdeniau jdeniau added this to the 6.0 milestone Mar 22, 2025
@jdeniau
Copy link
Member

jdeniau commented Mar 25, 2025

@volkanunsal I am digging up this issue, but it seems to be the logical thing to do.
I will try to implement that in 6.0 (it's breaking so I'm not updating the 5.x branch)

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.

2 participants