Error: non-constant expression...

spir denis.spir at
Fri Nov 26 11:16:08 PST 2010


void f () {
    static string[string] map = ["1":"un", "2":"du", "3":"tri"];
Error: non-constant expression ["1":"un","2":"du","3":"tri"]

I do not understand what is meant, and what I should do. I need 'static', it's a constant value for the func.
"static int[] a = [1,2,3];" is OK. Where's the difference?
Also tried const() and immutable(), who knows?, but no way. Search does not bring anything for "non-constant expression". (Also: pointer to dmd error messages welcome.)

Thank you all,
-- -- -- -- -- -- --
vit esse estrany ☣

More information about the Digitalmars-d-learn mailing list