Generic container

bearophile bearophileHUGS at lycos.com
Sat May 8 17:46:37 PDT 2010


wrzosk:
> Object[string] foo;
> foo["aaa"] = new AAA();

In D there is no the automatic boxing present in C#, so that can contain any object, but not any value. If you want to store any value, you need the values of that associative array to be of some kind of Box or Variant, etc. There are variant-like types both in Phobos and Tango, but you have to test if they work well for your purposes because it seems it's easy to put bugs in a Variant implementation.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list