aa literals

bearophile bearophileHUGS at lycos.com
Sat Mar 13 11:40:32 PST 2010


Ellery Newcomer:

> anyone know of a good (or any) syntax for an empty aa

Unfortunately "null" suffices where the function that receives knows the type of the AA it will receive. But I don't like this, a more typed style can be less bug prone.

So you can give a type to null:
cast(int[string])null

I have created a bit shorter template:
AA!(string, int)

But it doesn't gain much.

Something similar can be used for dynamic arrays:
cast(int[])null
With dynamic arrays you can also use (that I don't like) "null" and even the special []

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list