How to disable assigning a value to a property?
Jack Applegame
japplegame at gmail.com
Tue Jul 6 10:06:11 UTC 2021
Code:
```d
import std.stdio;
struct Field {
void opAssign(int a) {
writefln("Field.opAssign(%s)", a);
}
}
struct Register {
Field clock(int a) {
writefln("Register.clock(%s)", a);
return Field();
}
}
void main() {
Register register;
register.clock(1) = 10; // works, good
register.clock = 10; // works too, how to disable it?
}
```
How to disable `register.clock = 10;` but allow
`register.clock(1) = 10;`?
I want to get a compilation error on `register.clock = 10;`
More information about the Digitalmars-d-learn
mailing list