immutable/mutable strings
Zane
zane.sims at gmail.com
Wed Nov 19 17:35:23 PST 2008
Jarrett Billingsley Wrote:
> On Wed, Nov 19, 2008 at 8:13 PM, Zane <zane.sims at gmail.com> wrote:
> > Hey all,
> >
> > I am trying to get a full understanding of mutable/immutable string syntax. I understand it to be true that 'char[]' is mutable and that 'string' is immutable and is the same as invariant(char)[]. If I am incorrect on any of this, please let me know.
>
> That's all correct.
>
> > On a slightly different note, why does the compiler allow me to set an immutable value to a mutable type if it is an error? I am using dmd v1.033 -- Is this for v2.xx only? Thanks for any information that you can provide and sorry if these questions have already been answered.
>
> Yes. The whole section on const and invariant is D2 only. If you
> click the "D 1" link at the top left, you'll get to the D 1
> specification. The Digital Mars website kind of .. "guides" you into
> D2 with little mention of D1.
Thanks for your quick response. So then as in the example given, in D2, is this initialization allowed or was it a typo/mistake in the example?:
char[] s1 = "hello world";
Thanks again,
Zane
More information about the Digitalmars-d
mailing list