comparison run/a/associative_array_23_B.d @ 1556:ca435c6f02c8

DMD-1.014: associative array literals
author thomask
date Mon, 23 Jul 2007 18:46:06 +0000
parents
children
comparison
equal deleted inserted replaced
1555:01c289574a6d 1556:ca435c6f02c8
1 // $HeadURL$
2 // $Date$
3 // $Author$
4
5 module dstress.run.a.associative_array_23_B;
6
7 int main(){
8 auto arr = [4:"vier", 0:"null", 2:"zwei"];
9
10 if(3 != arr.length){
11 assert(0);
12 }
13
14 char[][] master_e = ["vier", "null", "zwei"];
15 int[] master_i = [4, 0, 2];
16
17 foreach(index, element; arr){
18 bool found = false;
19 foreach(pos, i; master_i){
20 if(index == i && element == master_e[pos]){
21 master_i = master_i[0 .. pos] ~ master_i[pos+1 .. $];
22 master_e = master_e[0 .. pos] ~ master_e[pos+1 .. $];
23 found = true;
24 break;
25 }
26 }
27 if(!found){
28 assert(0);
29 }
30 }
31 if(master_i.length){
32 assert(0);
33 }
34 return 0;
35 }