You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed when using Records that using map mutates the record and returns undefined. I assumed that map would return a new record and leave the old record unmodified.
varImmutable=require("immutable");varPerson=Immutable.Record({name: "Zach",age: 25});varme=newPerson();console.log(me.toString());// Record { name: "Zach", age: 25 }me.map(function(v,k){if(k==="age"){returnv+1;}else{returnv;}});// -> undefinedconsole.log(me.toString());// Record { name: "Zach", age: 26 }
The text was updated successfully, but these errors were encountered:
Yeah, I noticed that filter also had weird behaviour. I expected map to work because I think of records as similar to Map<string, any>, but maybe that's the wrong way to think about them, especially since something like filter would have to reinstate the defaults for filtered fields if it returns the record type, or return a different type altogether (Map).
I noticed when using Records that using
map
mutates the record and returns undefined. I assumed thatmap
would return a new record and leave the old record unmodified.The text was updated successfully, but these errors were encountered: