Advanced Swift: Values and References
Swift mutation model uses values and references to improve local reasoning and maintain performance. Find out the details in this course. By Ray Fix.
Learning path
This is part of the Advanced Swift learning path. View path.
Who is this for?
This course is for developers interested in getting a deeper understanding of the Swift language. It expects you to be comfortable with the basic syntax of Swift and to have perhaps written an app or two. You should be familiar with basic types in the Swift standard library.
Covered concepts
This course focuses on:
- Values
- References
- Copy on write
- Exclusivity
- inout
- self
Both value types and reference types can be used together to boost local reasoning without sacrificing performance.
References give you "spooky-action-at-a-distance" that can be leveraged to solve certain kinds of problems very well.
In this video, let's take a look at inout: the mechanism which underpins the mutation model in Swift.
Find out how self is passed implicitly to models and can be marked inout with mutating in this video.
The Law Exclusivity for memory is another Swift mechanism that improves local reasoning. Learn all about it in this video.
Copy-on-write is a great way to keep value semantics cheap. Let's take a look at how to implement it.
In this challenge you will try to implement a copy-on-write that reduces reference counting traffic.
You have seen how values and references work with Swift and how you can use COW to optimize performance and correctness with value type semantics.