immutable string

Michael pr at m1xa.com
Sat Apr 27 11:14:10 PDT 2013


According to http://dlang.org/const3.html

>The simplest immutable declarations use it as a storage class.
>It can be used to declare manifest constants.

So, immutable string s = "..."; should be a manifest constant.

If it is a constant that it can be used in switch(...).

switch(someStr)
{
    case s: ...; // Error: case must be a string or an integral 
constant, not s.
},

but string s = "..."; works good.

Why?


More information about the Digitalmars-d-learn mailing list