| |
Mutable and immutable data structures cannot be subtypes of each other because doing so would violate Liskov's substitution principle, which requires a subtype to work correctly in every context where its supertype is expected. While a mutable pair provides all the operations of an immutable pair, it breaks the implicit contract that immutable pairs maintain—that their contents never change—which is essential for operations like hashing that depend on consistency.
Read Full Article →
← More Tech news