`clear`ing a dynamic array

rsw0x via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Oct 24 07:34:32 PDT 2015


On Saturday, 24 October 2015 at 13:18:26 UTC, Shriramana Sharma 
wrote:
> Hello. I had first expected that dynamic arrays (slices) would 
> provide a `.clear()` method but they don't seem to. Obviously I 
> can always effectively clear an array by assigning an empty 
> array to it, but this has unwanted consequences that `[]` 
> actually seems to allocate a new dynamic array and any other 
> identifiers initially pointing to the same array will still 
> show the old contents and thus it would no longer test true for 
> `is` with this array. See the following code:
>
> [...]

use std.container.array


More information about the Digitalmars-d-learn mailing list