On Monday, 19 November 2018 at 01:24:02 UTC, Stanislav Blinov wrote:
Yup, that's because, like Rubn said, copying value types is trivial. Where it all comes to bite you is when you start having pointers, because you can't copy a const(T)* into a T*.

I'm not using reference types, but still:

```
struct S {
    int a;
    this(int a) {
        this.a = a;
    }
}

void main()
{
    immutable S d = 3;
}

```

onlineapp.d(10): Error: mutable method onlineapp.S.this is not callable using a immutable object onlineapp.d(10): Consider adding const or inout to onlineapp.S.this

const still leaves the first error, inout works though I don't know what it does.
Adding pure also works.

Reply via email to