why does clearing an array set its capacity to 0?

Ivan Kazmenko via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 1 13:40:34 PDT 2014


On Tuesday, 1 July 2014 at 13:03:54 UTC, Vlad Levenfeld wrote:
> I was mistaken earlier, decrementing the length counter also 
> sets the capacity to 0.

Besides just learning to use assumeSafeAppend (as mentioned 
already), I'd also recommend reading the article on D slices to 
deeper understand the ground you are building on top of:

http://dlang.org/d-array-article.html


More information about the Digitalmars-d-learn mailing list