Constructors and Value Semantics
A struct is a value type. Assigning a struct to another variable creates an independent copy; modifying the copy does not affect the original value.
A struct can define multiple init constructors (with different parameters) or define a primary constructor with the same name as the type. Parameters of the primary constructor can be decorated with let or var, simultaneously defining fields and constructor parameters.
The code on the right demonstrates constructor overloading and value semantics copying. Rectangle has two init constructors that create rectangles and squares, respectively. Variable b is an independent copy of a; modifying b does not affect a.
When defining a constructor, all instance member variables without initial values must be initialized, otherwise a compilation error will occur.
Try assigning a to b, then modify b.width and print both widths to verify that a remains unchanged.