is Dlang support Uniform initialization like c++

Ali Çehreli acehreli at yahoo.com
Fri Jun 30 16:08:37 UTC 2023


On 6/30/23 08:18, lili wrote:

> How too wirte this: addPoint({4,5}, {4,6})

In this case, arrays are better but only if you don't define a 
constructor, which you don't need for simple types like Point below:

struct Point {
     int x;
     int y;
}

void main() {
     // The type is explicit on the left-hand side
     Point[] points = [ {1,2} ];
}

Ali



More information about the Digitalmars-d-learn mailing list