immutable string

Minas Mina minas_mina1990 at hotmail.co.uk
Sat Apr 27 14:46:02 PDT 2013


On Saturday, 27 April 2013 at 18:14:11 UTC, Michael wrote:
> 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?

Because maybe string is already (immutable)char[]?


More information about the Digitalmars-d-learn mailing list