Tuple with `let` or `var`

Viewed 708

Let's say I have something like this:

func myFunc() -> (Any, Any)? {...}

func anotherFunc() {
    if var (a, b) = myFunc() {
        // a is mutated and accessed; b is accessed, but not mutated
        a = b
    }
}

I need var for the tuple as a is mutated, but Xcode complains that "bwas never mutated, consider using let" - which is a somewhat reasonable argument, but I can't really define the tuple as (var, let).

I guess I could use index to access the two elements instead of declaring them, circumventing this issue. But is there a better way?

1 Answers
Related