TrildaDevCenter a republié ceci
Do you ensure substitutability in your Equatable types? We know that Equatable types should satisfy 3 key conditions: 👉 a == a is always true (Reflexivity) 👉 a == b implies b == a (Symmetry) 👉 a == b and b == c implies a == c (Transitivity) But what about substitutability? Apple defines substitutability as follows: Equality implies substitutability—any two instances that compare equally can be used interchangeably in any code that depends on their values. To maintain substitutability, the == operator should take into account all visible aspects of an Equatable type. Exposing nonvalue aspects of Equatable types other than class identity is discouraged, and any that are exposed should be explicitly pointed out in documentation. Simply put: If 2 instances are considered equal, you should be able to replace one with the other in any part of your code that uses their values (e.g., variables or function arguments), and the program should behave the same way—it shouldn’t change the outcome or logic. Remember, equality is defined in terms of structural equality. So, are your Equatable types substitutable? --- If you're looking to improve your TCA skills, check out my free interactive tutorial on TCA best practices: https://lnkd.in/dJHaxm4E