Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Teacher here.

All my students eventually try {} + {}.

I'll bet on it to be the most intuitive.



Students are supposed to set things on fire and find various nifty features for learning's sake. But with experience - and the discovery that various such features largely overlap (eg. + and .extend()), one tends to grow out of that stance and become wiser.


It's intuitive to try, but it's not obvious what it actually does when keys overlap.


It’s obvious what you want done, and thankfully that is what’s going to be done.


the problem with overloading add is that add results in more than merge. merge is add minus the duplicate keys. students shouldn't learn wrong semantics.

{1:,2:} + {1:,3:} = {1:,2:,3:}




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: