Struct initialization has no effect or error?
mipri
mipri at minimaltype.com
Wed Oct 2 18:35:39 UTC 2019
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);
}
More information about the Digitalmars-d-learn
mailing list