On Sunday, 22 October 2017 at 07:23:14 UTC, meppl wrote:
On Sunday, 22 October 2017 at 01:02:06 UTC, EntangledQuanta wrote:
On Wednesday, 18 October 2017 at 08:56:21 UTC, Satoshi wrote:
...

ps, also i want something similar to this in D:
new Foo() {
  property1 = 42,
  property2 = "bar"
};
it might solve things better than named parameters https://wiki.dlang.org/DIP88

Well the thing is. This already exist for structs and I have always wondered why it doesn't exist for classes.

See:
https://dlang.org/spec/struct.html#static_struct_init

The example:

```
struct S { int a; int b; int c; int d = 7;}
static S x = { a:1, b:2};            // c is set to 0, d to 7
static S z = { c:4, b:5, a:2 , d:5}; // z.a = 2, z.b = 5, z.c = 4, z.d = 5
```

So it would make sense if classes supported it in the same way like:

```
class S { int a; int b; int c; int d = 7; }

static S x = new { a:1, b:2 };

// static auto x = new S { a:1, b:2 };

static S z = new { c:4, b:5, a:2, d:5 };

// static auto z = new S { c:4, b:5, a:2, d:5 };
```

Reply via email to