-
-
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
get or getIn on List using a key that is a string, object, or void 0 does not return correct notSetValue #486
Labels
Comments
Using |
Thank you for the report! |
I tried other types of keys: const {List} = require('immutable');
const foo = List();
[
'bar',
true,
false,
null,
void 0,
{},
42,
42.5
].forEach(function(key) {
const NOT_SET = {};
let ret = false;
ret = (foo.get(key, NOT_SET) !== NOT_SET) || ret;
ret = (foo.getIn([key], NOT_SET) !== NOT_SET) || ret;
ret = foo.has(key) || ret;
ret = foo.hasIn([key]) || ret;
if(ret) {
console.log('broken for key', key);
}
});
// broken for key bar
// broken for key undefined
// broken for key {} |
Thanks for your investigation! |
dashed
changed the title
get or getIn on List using a string key does not return correct notSetValue
get or getIn on List using a key that is a string, object, or void 0 does not return correct notSetValue
May 28, 2015
+1 |
Immutable.List([7]).getIn(0) // throws error whereas 7 was expected
Immutable.List([7]).getIn('0') // returns 7 as expected |
It looks like the second should probably also throw an error. getIn expects an Iterable collection of keys. Strings are Iterable but often not considered collections because that leads to confusion. Would you please open a separate issue for this other issue? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: