Associative arrays with void values

Doctor J nobody at nowhere.com
Sun Apr 12 08:50:03 PDT 2009


Sometimes you want to use an associative array just to track keys you've seen, or count distinct keys, and you don't care about the values.  The language will let you declare an array such as void[int]; but you can't actually do anything with it:

void main()
{
    void[int] voidmap;    // This compiles
    voidmap[1] = void;  // This doesn't
}

My question is, is this a common or useful enough special case to warrant inclusion in the language?  Or should I just go quietly and use a bool or a byte or something?





More information about the Digitalmars-d mailing list