Allocate N elements

Namespace rswhite4 at googlemail.com
Mon Jul 15 05:46:05 PDT 2013


On Monday, 15 July 2013 at 12:23:21 UTC, Adam D. Ruppe wrote:
> On Monday, 15 July 2013 at 11:46:54 UTC, Namespace wrote:
>> int[] arr = new int[sizeOfItems];
>
> Did you also try int[] arr = new int[](sizeOfItems)?

Example code:
----
void main()
{
	int[] arr1 = new int[512];
	writeln(arr1.length, "::", arr1.capacity);
	int[] arr2 = new int[](512);
	writeln(arr2.length, "::", arr2.capacity);
}
----

Output:
512::1019
512::1019


More information about the Digitalmars-d-learn mailing list