On Wednesday, 2 October 2019 at 18:35:39 UTC, mipri wrote:
On Wednesday, 2 October 2019 at 17:37:57 UTC, Brett wrote:
X y = {3};

works fine.

So one has to do

x[0] = y;

You could initialize x all at once. Complete example:

  import std.stdio;

  struct Point {
      int x, y;

      string toString() {
          import std.format : format;

          return format("(%d, %d)", x, y);
      }
  }

  void main() {
      Point[2] ps = [{0,0}, {4,4}];
      foreach (p; ps) writeln(p);
  }

The brace style struct initializer will likely be deprecated. Please see here https://github.com/dlang/DIPs/pull/169

Kind regards
Andre

Reply via email to