On Friday, June 08, 2012 14:41:10 Paul wrote: > If this works... > > D programming book section 4.1.9 Expanding > auto a = [87, 40, 10]; > a ~= 42; > assert(a== [87, 40, 10, 42]);
That compiles just fine. > why doesnt' this work? > > DeletedBlks ~= matchOld[0]; > > the dmd compiler comes back with > Error: cannot append type string to type string[ulong] > > Does this append operator only work for literals? You didn't give us the types of either DeletedBlks or matchOld[0]. However, from the error, it looks like DeletedBlks is a string[ulong], and matchOld[0] is a string. string[ulong] is an associate array - which means that it's a hash table - and appending doesn't make any sense with an associative array, because AAs aren't ordered. They take key-value pairs. So, something like DeletedBlks[42] = matchOld[0]; should compile - which creates the key-value pair of 42 and the value of matchOld[0]. Section 4.4 of TDPL discusses associative arrays (which you obviously aren't far from, since you're referring to section 4.1.9). So, read that section, and things should be clearer. - Jonathan M Davis