Static Associative Array

bearophile bearophileHUGS at lycos.com
Sun Mar 6 16:01:13 PST 2011


Jonathan M Davis:

> I'm pretty sure not. I think that it's currently suffering the same fate as stuff 
> like classes and is not yet able to be CTFEed. Some day...

This works:

import std.stdio;

string foo(int x) {
    auto aa = [1: "hello", 2: "red"];
    return aa[x];
}

enum string s = foo(1);

void main() {
    writeln(s);
}


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list