0Pricing
Swift Academy · Lesson

Memberwise Initializers and Custom Inits

Understanding auto-generated memberwise inits and writing custom initializers.

Welcome

Swift structs get a free *memberwise initialiser* that accepts all stored properties. But you can customise or extend this with your own initialiser logic.

Auto-generated Memberwise Init

```swift struct Point { var x: Double var y: Double } let p = Point(x: 3.0, y: 4.0) // auto-generated init ``` No need to write `init` yourself — the compiler provides one.

All lessons in this course

  1. Memberwise Initializers and Custom Inits
  2. Stored Properties and Property Observers
  3. Computed Properties in Structs
  4. Mutating Methods and Copy-on-Write Semantics
← Back to Swift Academy