What is the current point to empty/null associative arrays?

Chris Cain clcain at uncg.edu
Fri Nov 29 00:48:01 PST 2013


On Friday, 29 November 2013 at 08:32:12 UTC, Cooler wrote:
> ...

Try making fill array look more like this:

void fillArray(ref string[int] a) { a[10] = "A"; }

The issue is that an array (and/or associative array) is a value 
type. Basically, you can look at it as a struct with a pointer 
(and some extra info). If you don't pass it as a ref then 
reallocations (such as what happens when you add an item to an 
empty AA) will cause the two to not point to the same information 
anymore.


More information about the Digitalmars-d mailing list