On Thursday, 13 July 2023 at 11:55:17 UTC, Ki Rill wrote:
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?

Oh, is it because the first one is passed by value, but the second one is a reference?

Reply via email to