Associative Array Question

2020-12-31 Thread Chris Bare via Digitalmars-d-learn
I'm missing something about the way associative arrays are allocated. In the example below, case 1 and case 2 seem to be the same, a type indexed by a long. Case 2 fails with a Range violation. Can someone explain the difference? I found a work around (or the correct way) in case 3. struct Pro

Re: Associative Array Question

2020-12-31 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 1 January 2021 at 01:43:50 UTC, Chris Bare wrote: a1[10] = "testing a1"; this actually constructs a new thing since it is a straight x = y assignment. a2[10].name = "testing a2"; But this looks up something first. It doesn't construct a2[10], it

Re: Associative Array Question

2021-01-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/31/20 8:54 PM, Adam D. Ruppe wrote: On Friday, 1 January 2021 at 01:43:50 UTC, Chris Bare wrote:     a1[10] = "testing a1"; this actually constructs a new thing since it is a straight x = y assignment.     a2[10].name = "testing a2"; But this looks up something first. It do