All right, guys, in this module, we're going to be talking about Advanced Swift Properties. 1
Now, previously, we've already seen what properties are 2
and we've been using it throughout the course. Now, when we looked at objects and classes, we learned that 3
properties can be a constant or it can be a variable, and they allow us to store data relating to a particular 4
object or a class. 5
So, for example, in this case, we've got a car object that has a color property that's equal to red and 6
a type property that's equal to "coupe." 7
It doesn't matter if it's a constant or variable, they're both properties. 8
Now, more specifically, these types of properties can be described as stored properties because, essentially, 9
they're just a container that can take a value and you could store it inside the container. 10
And when you later need to use this stored property, you can take out the value and use it. 11
Now, in this lesson and others in the module, we're going to be talking about a different type of property, 12
and these are called computed properties. 13
And what these allow us to do is to create properties whose values can be calculated on the go by using 14
the code that we write and that will make it really similar to an Excel spreadsheet. 15
So for example, if we were trying to work out the area of a particular wall, say, in our bathroom, and we 16
actually recorded it wrong, instead of being 1.5 by 2.6 meters, actually, that wall height was 2.3 meters. 17
Well, then in that case, the area can auto-update and be calculated or computed based off the change in 18
the height, 19
and this is exactly what we're going to do with our code. And the code that we're going to write is going 20
to be super useful because we're going to use it to solve the biggest issue that mankind has which is, 21
of course, how many pizzas should you buy, so that you can feed everybody who's in your house. 22
This has mystified mankind for a long time. 23
And finally, we're going to be able to use computed properties to solve this problem. 24
So once you're ready, head over to the next lesson and we'll get started right away.