Can now use alias for collapsing multiple fields in nested structs
Walter Bright
newshound2 at digitalmars.com
Thu Jan 2 19:08:06 UTC 2025
On 1/2/2025 6:32 AM, Derek Fawcus wrote:
> The closest native equivalent in D, would seem to be the following, making use
> of the new facility.
>
> ```D
> struct outer {
> int a;
> struct inner_ {
> int b;
> int c;
> }
> inner_ inner;
> int d;
> alias b = inner.b;
> alias c = inner.c;
> };
> ```
>
> Or is there a nicer way to write that in D?
```
struct outer {
int a;
struct {
int b;
int c;
}
int d;
}
```
More information about the Digitalmars-d
mailing list