Insert an element into an Associative Array ?

Jonathan M Davis jmdavisProg at gmx.com
Thu Apr 5 21:26:54 PDT 2012


On Friday, April 06, 2012 11:46:24 Ary Manzana wrote:
> By the way, why is it called "associative array"? A name like Hash or
> Map would be much better. Everyone knows what a Hash means. I don't see
> anyone using "associative array" to refer to a Hash. And I think this is
> the source of the confusion Chris has...
> 
> I mean, you can't append to an associate array. What part of it makes it
> an "array"?

The term associative array is quite correct: 
http://en.wikipedia.org/wiki/Associative_array

Also, static arrays are arrays, but you can't append to them. And most 
programming languages with arrays don't have any form of array concatenation 
(certainly, among C-based languages, D is the only one that I'm aware of). 
They do with strings, but strings generally aren't arrays in such languages. 
So, the fact that something is an array says _nothing_ about whether you can 
append to it. The fact that you can with D's dynamic arrays is a fantastic 
feature, but it is by no means guaranteed simply because they're arrays.

And the very nature of an associative array pretty clearly doesn't make any 
sense with appending, since appending doesn't involve a key-value pair at all, 
so I'm honestly very surprised to see that anyone would make that mistake.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list