Logesh Pillay
Logesh Pillay

Reputation: 117

update struct - d programming language

In initialising a struct, we can go for

Foo  a = {1, 7};

How do I update values as the program runs?

These forms don't work:

a = {2, 9};
a = {fst:2, snd:9};

Is the only way the long:

a.fst = 2;
a.snd = 9;

Seems inefficient. What if we have losts of members?

Upvotes: 0

Views: 72

Answers (1)

ratchet freak
ratchet freak

Reputation: 48216

you could create a temporary second struct:

Foo b = {2,9};
a=b;

or use a constructor to create the temporary:

a = Foo(2,9);

Upvotes: 1

Related Questions