Global const variables

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 21 04:02:15 PDT 2014


Szymon Gatner:

>> const int[] a;
>> int[] b;
>>
>> static this()
>> {
>>    b = [1];
>>    a = b;
>> }
>
> Ant this code works? What is the point of const then if you can 
> assign it to mutable slice?

It works, and I think it should work. Inside the (module) 
constructor the const state is handled differently.

Thank you for the example, safety0ff.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list