it’s possible to not only defer initialisation of a let constant, but to involve calculations depending on the rest of your application.

2) Variables

var myVariable: Int = 3

You can change this at any point in time: in an initialiser, and while the application is running. (OK, changing var declared in structs is a bit more involved, but the principle is sound.)

3) Computed Properties

var privateValue: Int = 15

var calculatedValue: Int {
return privateValue * 2
}

Here, the calculation depends on other factors. A typical use case is to set the height and width of a rectangle, and calculate its area. Computed properties are read-only, and are calculated every time they are accessed.

This value gets calculated exactly once, during initialisation. If you prefix it with ‘lazy’, the initialisation happens only when the value is retrieved – if nobody ever calls this, it will never be calculated, making it ideal for expensive setup calls. Afterwards, this variable behaves like any ordinary variable: you can assign any other value to it.