Poll: do you use @property semantics?
rikki cattermole
rikki at cattermole.co.nz
Wed Sep 14 21:50:21 UTC 2022
On 15/09/2022 9:42 AM, IGotD- wrote:
> So @property is similar to C# get/set?
No. Getting and setting behavior via a method is not associated with
@property.
https://dlang.org/spec/function.html#property-functions
Works:
```d
struct Foo
{
int data() { return m_data; } // read property
int data(int value) { return m_data = value; } // write property
private:
int m_data;
}
void main() {
Foo foo;
foo.data = 234;
}
```
More information about the Digitalmars-d
mailing list