On assigning const to immutable
Ki Rill
rill.ki at yahoo.com
Thu Jul 13 11:55:17 UTC 2023
Why does the first example `class A` work, but the second one
with `class B` does not?
```D
class A {
immutable int a;
this(in int a) {
this.a = a;
}
}
class B {
immutable int[] b;
this(in int[] b) {
this.b = b;
}
}
void main()
{
auto a = new A(1);
auto b = new B([1, 2]);
}
```
It implicitly converts `const` to `immutable`, but fails to do
the same with an array. Is it intentional? Why?
More information about the Digitalmars-d-learn
mailing list