Perhaps this is a silly question and I'm completely misunderstanding how passing variable in Swift works, but I was under the impression that Swift was pass by copy by default, and you could use the inout
keyword to denote passing by reference.
How come then, if I have a function that has a UIView
parameter, I can change, say, the backgroundColor
of the UIView
within that function, and it's reflected outside the function. If the function creates a local copy when passed, how is this affecting the passed variable?
Why does that not require inout?