Recipe: Comparing Constraints
All constraints use a fixed structure in the following form, along with an associated priority:
view1.attribute (relation) view2.attribute * multiplier + constant
Each element of this equation is exposed through a constraint’s object properties—namely priority, firstItem, firstAttribute, relation, secondItem, secondAttribute, multiplier, and constant. These properties make it easy to compare two constraints.
Views store and remove constraints as objects. If two constraints are stored in separate memory locations, they’re considered unequal, even if they describe the same conditions. To allow your code to add and remove constraints on-the-fly without storing those items locally, use comparisons.
Recipe 5-1 introduces ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access