-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering Swift 5.3
By :

Structures are value types; when we pass instances of a structure in our application, we pass a copy of the structure and not the original structure. Classes are reference types; therefore, when we pass an instance of a class within our application, a reference to the original instance is passed. It is very important to understand this difference. We will discuss a very high-level view here but will provide additional details in Chapter 18, Memory Management.
When we pass structures within our application, we are passing copies of the structures and not the original structures. This means that the function gets its own copy of the structure, which it can change as needed without affecting the original instance of the structure.
When we pass an instance of a class within our application, we are passing a reference to the original instance of the class, therefore, any changes made to the instance of the class will persist.
To illustrate the...