Re: opOpAssign of AA: defined behavior?

2020-06-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/23/20 5:15 AM, WebFreak001 wrote: I have the following code:     double[string] foo;     foo["a"] += 1; how is the opOpAssign on the AA defined? Is it defined to set the value to the value to the right of the opOpAssign if it isn't set for primitives or does it add the given value

Re: opOpAssign of AA: defined behavior?

2020-06-23 Thread Eduard Staniloiu via Digitalmars-d-learn
On Tuesday, 23 June 2020 at 09:15:57 UTC, WebFreak001 wrote: [...] it will give me a range violation at runtime and not init it for me at all. There is `aa.require("a", Foo.init) += 4;` now which solves this, but I would prefer having the small simple syntax well defined for all types

opOpAssign of AA: defined behavior?

2020-06-23 Thread WebFreak001 via Digitalmars-d-learn
I have the following code: double[string] foo; foo["a"] += 1; how is the opOpAssign on the AA defined? Is it defined to set the value to the value to the right of the opOpAssign if it isn't set for primitives or does it add the given value onto T.init? Doing foo["b"]++; gives