Send empty assoc array to function

JN 666total at wp.pl
Fri Jul 10 11:57:38 UTC 2020


On Friday, 10 July 2020 at 03:59:37 UTC, Mike Parker wrote:
> Meh. You could say the same about foo(int[]), or 
> foo(SomeClass). AAs are reference types. Reference type 
> instances can be null.

Oh, that actually makes sense. I always thought assoc arrays are 
value types.

Anyway, even if they are reference type, I still would consider 
[] and null different types of values. [] conveys to me that the 
object exists, but is empty. null conveys to me that the object 
exists and cannot be used.

int[int] a = null;
a[5] = 6;

This kind of code just looks weird... yes, I know the " = null " 
part is excessive, but still.


More information about the Digitalmars-d-learn mailing list