Is this a violation of const?
Salih Dincer
salihdb at hotmail.com
Sat Jul 30 07:15:45 UTC 2022
On Saturday, 30 July 2022 at 06:04:16 UTC, ag0aep6g wrote:
>
> Yes. Here's a modified example to show that you can also
> violate `immutable` this way:
It's possible to do this because it's immutable. You don't need
an extra update() function anyway.
```d
void main()
{
auto s = S("test A");
s.update = (_) { s.s = _; };
s.update("test B");
assert(s.s == "test B");
s.s = "test C";
assert(s.s == "test C");
} // No compile error...
```
SDB at 79
More information about the Digitalmars-d-learn
mailing list