Swift 6 · Basics and optionals

Define functions

Argument labels make calls read like sentences. _ removes a label.

func area(width: Double, height: Double) -> Double {
    width * height
}

let a = area(width: 3, height: 4)

Official Swift 6 documentation

More basics and optionals commands

All basics and optionals commands · Swift 6 cheatsheet

Was this page helpful?