On Wed, Mar 21, 2012 at 07:29:44PM +0100, David Nadlinger wrote: > On Wednesday, 21 March 2012 at 18:27:30 UTC, H. S. Teoh wrote: > >A question was asked on the d-learn forum about why this throws a > >RangeError: > > > > int[string][int] map; > > map["abc"][20]++; > > Wait a second – aren't AAs _supposed_ to throw if accessing a key > that doesn't exist yet? To be able to increment something, there > already has to be a value to start from… [...]
If it doesn't exist, it should default to typeof(value).init, IMO. But perhaps that was the wrong example to use. What if you wanted to do this: map["abc"][20] = 1; Currently this doesn't work. You have to explicitly create map["abc"] first. T -- Time flies like an arrow. Fruit flies like a banana.