data containers
torhu
no at spam.invalid
Sat Jul 5 06:48:34 PDT 2008
Moritz wrote:
> Thanks again, torhu. I understand multidimensional arrays (at least I
> think so :-) ), and that these arrays contain pointers to other arrays.
>
> I thought the .length() operation would make the array static in its
> size, thats why I didnt try this earlier.
>
> But after reading what you wrote, I still dont see why I cant go without
> the length(), by just using ~=, like:
>
> ScreenElement[][] layer_map;
>
> int add_element(ScreenElement new_element, uint layer)
> {
> layer_map[layer] ~= new_element;
> }
>
> You wrote setting the length and using ~= both increase the size of the
> array, but I get an ArrayBoundsError when using the ~=.
That probably means you're not doing quite what you think you're doing.
Try adding an assert and see if it gets triggered:
int add_element(ScreenElement new_element, uint layer)
{
assert(layer < layer_map.length, "there's no layer with that number");
layer_map[layer] ~= new_element;
}
>
> And thank you all for your help so far!!!!
>
My pleasure.
More information about the Digitalmars-d-learn
mailing list