Is it possible to prevent the reassignment of variables that is not transitive in D2?

Is it possible to prevent the reassignment of variables that is not transitive in D2?

For instance:

final int[] a = [0];
a[0] = 1; // OK.
a = []; // ERROR.

I can only see constand immutablehere: http://www.dlang.org/const3.html

+5
source share
1 answer

No. You have constboth immutable, and they are transitive (they really don't work if they weren't). You can do

const(int)[] a = [0];
a[0] = 1; // ERROR.
a = []; // OK;

But not what you are looking for.

, const immutable . , immutable ( ), , , immutable const, const , . , , . .

+6

All Articles