Custom Value Types
In most traditional object-oriented programming languages, we create classes (which are reference types) as blueprints for our objects. In Swift, unlike other object-oriented languages, structures have much of the same functionality as classes, however, they are value types. Apple has said that we should prefer value types, such as structures, to reference types, but what are the differences between a reference type and a value type?
In this chapter, you will explore the following topics:
- The differences between value types and reference types
- Why recursive data types cannot be created as a value type
- How to implement copy-on-write in your custom type
- How to conform to the
As we saw in Chapter 8 ...