By trial&error I found some facts about tuples and mutability in Swift, but would like to learn about actual rules. Consider such code:
class T
{
var f : String = "hello"
}
let a = T();
let b = (f : "hello", "");
a.f = "world";
b.f = "world";
println(a.f)
println(b.f)
a
behaves like fixed reference (you can change any member you like of the object, just not the main reference). So it is like readonly
in C#.
But b
behaves more like constant value -- the above code does not compile. One could say that let
(or var
) is applied to all the members of the tuple.
But it is guessing from my part -- so back to my question. What are the rules for tuples and their mutability?