Thread overview | |||||
---|---|---|---|---|---|
|
June 02, 2011 array of constants? | ||||
---|---|---|---|---|
| ||||
I'm trying to define an array of constant like: === immutable string[int] MyDict = [ 1: "monday", 2: "tuesday", ]; ==== And I keep having compiler error: Error 1 Error: non-constant expression [1:"monday",2:"tuesday"] C:\Dev\DTest\DTest1\Dexperiment\LCIDs.d 9 what can I do? how do I do that? |
June 02, 2011 Re: array of constants? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lloyd Dupont | You need to set it in a static constructor immutable string[int] MyDict; static this () { MyDict = cast(string[int]) [ 1: "monday", 2: "tuesday" ]; } |
June 03, 2011 Re: array of constants? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Etherous | thanks! "Etherous" wrote in message news:is8dbh$n22$1@digitalmars.com... You need to set it in a static constructor immutable string[int] MyDict; static this () { MyDict = cast(string[int]) [ 1: "monday", 2: "tuesday" ]; } |
Copyright © 1999-2021 by the D Language Foundation