Wrong lowering for a[b][c]++

Ali Çehreli acehreli at yahoo.com
Wed Mar 21 11:58:34 PDT 2012


On 03/21/2012 11:29 AM, 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]++;

Hey! That syntax is following the broken syntax of C and C++. ;)

This works:

import std.stdio;

void main()
{
     int[string][int] map;
     map[20]["abc"]++;

     writeln(map);
}

The output:

[20:["abc":1]]

Ali



More information about the Digitalmars-d mailing list