Memory allocation in D (noob question)

Derek Parnell derek at psych.ward
Wed Dec 5 13:06:48 PST 2007


On Wed, 05 Dec 2007 16:18:46 +0000, Regan Heath wrote:

> [example pasted again for clarity]
> 
>  > string ab = "ab".idup;
>  > string a = ab[0..1];
>  > a ~= "c";
>  > writefln("ab = ",ab); // also outputs "ac"

However, this is fine ...

 string ab = "ab";
 string a = ab[0..1];
 a ~= "c";
 writefln("ab = ",ab); // outputs "ab"
 writefln("a  = ",a);  // outputs "ac"

So it seems that the '.idup' property is affecting things.
-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list