Best way to clear dynamic array for reuse

cym13 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 13 05:23:36 PDT 2016


On Wednesday, 13 July 2016 at 12:22:55 UTC, Lodovico Giaretta 
wrote:
> On Wednesday, 13 July 2016 at 12:20:07 UTC, cym13 wrote:
>> The best option would be a.clear(). From the language specs:
>>
>> “Removes all remaining keys and values from an associative 
>> array. The array is not rehashed after removal, to allow for 
>> the existing storage to be reused. This will affect all 
>> references to the same instance and is not equivalent to 
>> destroy(aa) which only sets the current reference to null.”
>
> I don't think OP is using associative arrays, but dynamic 
> arrays (if I understood correctly).

You're right, my bad, I read too fast :/


More information about the Digitalmars-d-learn mailing list