Skip to content

26 Value equality ​

Values compare by their contents rather than by creation event.

norm
value Position {
  Integer row
  Integer column
}

main() {
  Position first = Position(row: 2, column: 4)
  Position same = Position(row: 2, column: 4)
  Position other = Position(row: 2, column: 5)
  printLine(first == same)
  printLine(first == other)
}

Expected output:

text
true
false

Two separately constructed positions with the same fields compare equal. Changing only column makes the third position unequal; nested value fields follow the same content rule.

Try it: Change other.column to four and predict both comparisons.

Precise rules: Reference.

Norm 0.25