Hacker News new | past | comments | ask | show | jobs | submit login

Yes, I'd have lesson explaining it's behavior, how it works any why it works this way and maybe assign homework to extend it to support uniqueness based on structural equality.



You can't extend it to support uniqueness based on structural equality, because the Set type uses == to test, and there is no means in the language of overriding that.


You can extend it, trivial one would be by subclassing and overriding methods to iterate over all entries doing deep-equal. Better complexity can be achieved by hashing (doesn't need to be collision free) and scanning subsets per hash etc.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: