Null references – literally when a variable has no value – were invented by Tony Hoare way back in 1965. When asked about it in retrospect, he said “I call it my billion-dollar mistake” because they lead to so many problems.
This is the last day that you’ll be learning the fundamentals of Swift, and it’s devoted exclusively to Swift’s solution to null references, known as optionals. These are a really important language feature, but they can hurt your brain a little – don’t feel bad if you need to repeat some tutorials a few times.
In essence, an optional is trying to answer the question “what if our variable doesn’t have any sort of value at all?” Swift wants to make sure all our programs are as safe as possible, so it has some very specific – and very important! – techniques for handling this eventuality.
Today you have five tutorials to work through, where you’ll meet optionals, optional unwrapping, nil coalescing, and more. Once you’ve watched each video and optionally gone through the extra reading, there are short tests to help make sure you’ve understood what was taught.
Tip: Yes, there is optional reading about optionals, but these optionals aren’t empty!
Hit Send below to start a virtual conversation with me.
Need help? Tweet me @twostraws!
SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.
Link copied to your pasteboard.