When are associative arrays meant to throw a RangeError?

Ben Davis entheh at cantab.net
Sat Feb 18 11:21:09 PST 2012

Self-correction: I evidently didn't read that array.init returns null 
for static arrays. But the point holds for dynamic ones.

On 18/02/2012 19:15, Ben Davis wrote:
> On 18/02/2012 13:22, Daniel Murphy wrote:
>> "Ben Davis"<entheh at cantab.net> wrote in message
>> news:jho2mf$2a1t$1 at digitalmars.com...
>>> Starting with magic initialisation then...
>> I meant a different magic initialization:
>> int[int] aa = null;
>> aa[3] = 7; // aa is magically not null any more
> I've seen some line-blurring between 'null' and 'empty' for dynamic
> arrays (non-associative). Specifically, I read that array.init returns
> null for both static and dynamic, but I think I also read that a dynamic
> array's default value is the empty array. I also observed that null~[1]
> == [1], and I wondered if actually 'null' becomes an empty array when
> cast to dynamic array and they're effectively the same thing.
> If I'm right, then the same could be true for assoc arrays - that 'null'
> cast to an assoc array type becomes an empty assoc array. Which would
> explain the magic you're seeing.

More information about the Digitalmars-d mailing list