Syntax sugar for {} with structs
Paul Backus
snarwin at gmail.com
Fri Jul 1 15:55:50 UTC 2022
On Friday, 1 July 2022 at 11:51:57 UTC, ryuukk_ wrote:
> Maybe it could be a syntax sugar for `state.buffer_list =
> state.buffer_list.init`
Simple enough to write a utility function that does this:
```d
void reset(T)(ref T obj)
{
obj = typeof(obj).init;
}
```
Now you can write `reset(state.buffer_list)` (or
`state.buffer_list.reset` if you prefer). No need to repeat
yourself.
More information about the Digitalmars-d
mailing list