On Wednesday, October 2, 2019 11:48:46 PM MDT Mike Parker via Digitalmars-d-
learn wrote:
> On Thursday, 3 October 2019 at 04:57:44 UTC, mipri wrote:
> > On Thursday, 3 October 2019 at 04:33:26 UTC, Brett wrote:
> >> I was trying to avoid such things since X is quite long in
> >> name. Not a huge
On Thursday, 3 October 2019 at 04:57:44 UTC, mipri wrote:
On Thursday, 3 October 2019 at 04:33:26 UTC, Brett wrote:
I was trying to avoid such things since X is quite long in
name. Not a huge deal... and I do not like the syntax because
it looks like a constructor call.
It is a constructor
On Thursday, 3 October 2019 at 04:33:26 UTC, Brett wrote:
I was trying to avoid such things since X is quite long in
name. Not a huge deal... and I do not like the syntax because
it looks like a constructor call.
It is a constructor call, though. You can define your own as well:
#!
On Wednesday, 2 October 2019 at 17:54:20 UTC, H. S. Teoh wrote:
On Wed, Oct 02, 2019 at 05:37:57PM +, Brett via
Digitalmars-d-learn wrote:
struct X { int a; }
X[1] x;
x[0] = {3};
or
x[0] = {a:3};
fails;
This works:
x[0] = X(123);
Should the syntax not extend to the case
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
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;
On Wednesday, 2 October 2019 at 17:54:20 UTC, H. S. Teoh wrote:
On Wed, Oct 02, 2019 at 05:37:57PM +, Brett via
Digitalmars-d-learn wrote:
struct X { int a; }
X[1] x;
x[0] = {3};
or
x[0] = {a:3};
fails;
This works:
x[0] = X(123);
I'd knew I'd gotten the impression from
On Wed, Oct 02, 2019 at 05:37:57PM +, Brett via Digitalmars-d-learn wrote:
> struct X { int a; }
>
> X[1] x;
>
> x[0] = {3};
>
> or
>
> x[0] = {a:3};
>
> fails;
This works:
x[0] = X(123);
> Should the syntax not extend to the case of array assignment?
Arguably it should. But
struct X { int a; }
X[1] x;
x[0] = {3};
or
x[0] = {a:3};
fails;
Should the syntax not extend to the case of array assignment?
This avoids a double copy.
X y = {3};
works fine.
So one has to do
x[0] = y;