Nice way of copying an immutable value while changing only a few of its many properties?

Because parameter order matters in Swift. So the following is fine (ie no invalid redeclarations):

struct BlahBlah {
    var a: Int = 5
    var b: Int = 6

    init(a: Int, b: Int) {
        self.a = a; self.b = b; print("I'm one initializer.")
    }
    init(b: Int, a: Int) {
        self.a = a; self.b = b; print("I'm another initializer.")
    }

    func foo(x: Bool, y: Bool) { print("I'm one method.") }
    func foo(y: Bool, x: Bool) { print("I'm another method.") }
}

This will not change (as it would be a hugely breaking change).

1 Like