I have this weird behavior in swift where I set a variable to a new value, however, it gets reset immediately. I have broken down the non-working code down to this: