Swift 6 · Types and protocols

Classes

Classes are reference types and support inheritance.

class Vehicle {
    var wheels = 4
    func describe() -> String { "\(wheels) wheels" }
}

class Bike: Vehicle {
    override init() { super.init(); wheels = 2 }
}

Official Swift 6 documentation

More types and protocols commands

All types and protocols commands · Swift 6 cheatsheet

Was this page helpful?