2 ms·
While I mostly agree, there still should be a way in Swift to make a collection of virtual dispatch objects, including hash-based collections. But this can be d
by Manishearth 11y ago
While I mostly agree, there still should be a way in Swift to make a collection of virtual dispatch objects, including hash-based collections. But this can be done in a separate library since this isn't a language restriction.
Might try to write one tomorrow, really.
- jcizzle 11y agoThis is all possible - the issue is that you still must define equality if you want to put it in a collection that cares about equality.
- Manishearth 11y agoSure, and then you redefine it so that it can handle protocol objects (where a things of different concrete types are inequal). You may need a new Equatable/Hashable-esque protocol for this, but it should be doable.