In The Swift Programming Language, in the section on Strings, subsection String Mutability, it says this:
You indicate whether a particular
String
can be modified (or mutated) by assigning it to a variable (in which case it can be modified), or to a constant (in which case it cannot be modified):
and gives example code:
var variableString = "Horse"
variableString += " and carriage"
// variableString is now "Horse and carriage"
let constantString = "Highlander"
constantString += " and another Highlander"
// this reports a compile-time error - a constant string cannot be modified”
The book in iBooks here, or in a web browser here.
In the next paragraph it claims that "strings are value types".
My question: that doesn't look like a mutable string to me. It looks like what I'm used to in Java (or C#, Python, and others): immutable string objects with mutable variable bindings. In other words, there was an object "Horse" and then it created a new String object "Horse and carriage" and set it to the same variable. And since there is no way to tell the difference between an reference to an immutable object versus a value type (right?), I wonder: why are they describing it like this? Is there any difference between these Swift strings and the way it is in Java? (Or C#, Python, Objective-C/NSString)