3 ms·
>If anything it enables the enforcement of strong invariants and leads to better and safer code. How?? If a container have `get(K)->V` and `remove(K)->V` then
by kajaktum 4y ago
>If anything it enables the enforcement of strong invariants and leads to better and safer code.
How?? If a container have `get(K)->V` and `remove(K)->V` then how does it preserve this invariant? This is an impossible contract to satisfy once you try to push once and pop twice. The container is promising you something that it can't satisfy, I would rather have a container that's honest with `get(key)->Maybe(value)`.
- mgaunard 4y agoYou have it backwards, the strong invariant is that you have a container and not a maybe container.