On Friday, 19 October 2012 at 13:41:53 UTC, Jacob Carlborg wrote:
On 2012-10-19 11:42, Marco Leise wrote:
When you extend the length of an array, it is filled with
the static .init value for the type, which is null here. I
think you'll have to create the objects manually.
foreach (ref foo; a)
On 2012-10-19 11:42, Marco Leise wrote:
When you extend the length of an array, it is filled with
the static .init value for the type, which is null here. I
think you'll have to create the objects manually.
foreach (ref foo; a) foo = new Foo;
Is this possible:
a[] = new Foo;
?
--
/Jacob Ca
On 10/19/12 11:09, m0rph wrote:
> Suppose I have a dynamic array of classes, something like:
>
> class Foo {
> int value;
> }
>
> Foo[] a;
>
> Now I want to resize it and initialize new items with default values, so I do
> following:
>
> a.length = 10;
> a[0].value = 1;
>
> And by executi
Am Fri, 19 Oct 2012 11:09:42 +0200
schrieb "m0rph" :
> Suppose I have a dynamic array of classes, something like:
>
> class Foo {
> int value;
> }
>
> Foo[] a;
>
> Now I want to resize it and initialize new items with default
> values, so I do following:
>
> a.length = 10;
> a[0].value =
Suppose I have a dynamic array of classes, something like:
class Foo {
int value;
}
Foo[] a;
Now I want to resize it and initialize new items with default
values, so I do following:
a.length = 10;
a[0].value = 1;
And by executing the last line of code I've got a segmentation
fault. App