Properties can be added to a class or struct (technically enums too, see "Computed Properties" example). These add values that associate with instances of classes/structs:
class Dog {
var name = ""
}
In the above case, instances of Dog
have a property named name
of type String
. The property can be accessed and modified on instances of Dog
:
let myDog = Dog()
myDog.name = "Doggy" // myDog's name is now "Doggy"
These types of properties are considered stored properties, as they store something on an object and affect its memory.