Setting field of struct object

Danilo codedan at aol.com
Mon Jan 22 09:52:39 UTC 2024


On Monday, 22 January 2024 at 08:54:21 UTC, Danilo wrote:
> It's common OOP style in some frameworks.

With latest D you can also just use named parameters:
```d
import std;

struct Person {
     /*private*/ string name, email;
     /*private*/ ulong age;
}

void main() {
     auto p = Person(
         name: "Tom",
         email: "joelcnz at gmail.com",
         age: 44,
     );

     writeln(p);
}
```



More information about the Digitalmars-d-learn mailing list