Array Append

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Jun 8 08:46:49 PDT 2012


On 08.06.2012 18:50, Paul wrote:
> On Friday, 8 June 2012 at 12:50:56 UTC, Dmitry Olshansky wrote:
>> On 08.06.2012 16:42, Paul wrote:
>>> On Friday, 8 June 2012 at 12:41:13 UTC, 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]);
>>>>
>>>> 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?
>>>
>> because it's associative array and it doesn't support "appending"
>> meaningfully ?
>>
>> AA with integer keys != plain arrays
>
> string[ulong] is a standard array
> ulong[string] would be associative....NO?
>

While I see  logic, but no.

And the reason is that associative means non-contiguous, that is 
deletedBlks[0] is not next to deletedBlks[1] etc. More over there could 
be gaps.. And most important there is no order of elements.
It's just a map: given integer - give a string.

And plain arrays are more then that :)

-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list