Structures as values
The term value has an important meaning when it comes to structs in Swift, and that’s because structs create what are known as value types.
A value type is a type whose instances are copied on assignment.
var a = 5 var b = a
print(a) // 5
print(b) // 5
a = 10
print(a) // 10
print(b) // 5
This copy-on-assignment behavior means that when a is assigned to b, the value of a is copied into b. That’s why it’s important read = as "assign", not "is equal
to" (which is what == is for).
How about the same principle, except with the DeliveryArea struct:
As with the previous example, area2.range didn’t pick up the new value set in area1.range. This demonstrates the value semantics of working with structs. When you assign area2 the value of area1, it gets an exact copy of this value. area1 and area2 are still completely independent!