immutable string
Namespace
rswhite4 at googlemail.com
Sat Apr 27 15:23:36 PDT 2013
On Saturday, 27 April 2013 at 21:46:03 UTC, Minas Mina wrote:
> 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[]?
immutable string is converted to immutable(string) which is
converted to immutable(immutable(char)[]).
So no error with that.
More information about the Digitalmars-d-learn
mailing list