www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Construct D Arrray with explicit capacity

reply =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
Is there a recommended way to create a builtin D array with a 
given capacity?

I'm aware of the `.capacity` property.

Is it ok to mutate it?
Oct 30 2016
next sibling parent =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Sunday, 30 October 2016 at 18:10:09 UTC, Nordlöw wrote:
 Is it ok to mutate it?
I just checked. It is not.
Oct 30 2016
prev sibling parent reply arturg <var.spool.mail700 gmail.com> writes:
On Sunday, 30 October 2016 at 18:10:09 UTC, Nordlöw wrote:
 Is there a recommended way to create a builtin D array with a 
 given capacity?

 I'm aware of the `.capacity` property.

 Is it ok to mutate it?
you cant mutate capacity directly because its only a getter but you could use arr.reserve(someVal);
Oct 30 2016
parent =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Sunday, 30 October 2016 at 18:26:54 UTC, arturg wrote:
 you cant mutate capacity directly because its only a getter but 
 you could use arr.reserve(someVal);
Thx!
Oct 30 2016