[Issue 3814] Mutation of immutable string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 18 10:33:47 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3814


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> 2010-02-18 10:33:46 PST ---
s is not immutable, only the data it points to.

s is of type immutable(char)[], which means the array itself can be added to or
reassigned to another slice of data, but the data it points to is immutable. 
It is read "an array of immutable chars" instead of "an immutable array of
chars".

If you want an immutable string, do:

immutable string s = "ab";

Which you will not be able to change the length of.

Also could do:

immutable char[] s = "ab";

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list