Allow default argument expressions to reference earlier parameters

a DIY workaround that works today:

func foo(x: Int, y: Int! = nil) {
    let y = y ?? x
    print(x, y)
}

foo(x: 1, y: 2) // prints: 1, 2
foo(x: 1) // prints: 1, 1
foo(x: 1, y: nil) // strange I admit, but still prints 1, 1
4 Likes