How do I generate `setX` methods for all private mutable variables in a class?

Basile B. b2.temp at gmx.com
Tue Jun 6 08:20:10 UTC 2023


On Monday, 5 June 2023 at 15:28:34 UTC, Paul Backus wrote:
> Is there a reason you can't just make these fields `public`?

My bet is that OP actually wants to generate something like

```d
void setStrokeWidth(uint value)
{
     if (value = strokeWidth) return;
     strokeWidth = value;
     redraw();
     // or maybe...
     // needRedraw = true;
}
```

that's a common pattern in 2D graphics libraries


More information about the Digitalmars-d-learn mailing list