| James J. Gavan 2006-03-09, 6:55 pm |
| Frank Swarbrick wrote:
> Anyone for "associate arrays"?
>
> In the language D you can do the following:
>
> int[char[]] b; // associative array b of ints that are
> // indexed by an array of characters.
> // The KeyType is char[]
> b["hello"] = 3; // set value associated with key "hello" to 3
> func(b["hello"]); // pass 3 as parameter to func()
>
> This is from http://www.digitalmars.com/d/arrays.html#associative if you're
> interested. What I like about it is it's directly supported by the
> language.
<snip>
If you look at the listing I gave Oliver of the M/F Collection
hierarchy, you will see references to classes on Arrays. No idea if
people use them much. (Yes, they are used indirectly to support 'true'
Collection classes). But the important factor is your, "What I like
about it is it's directly supported by the language".
Perhaps it can be achieved using M/F methods - but if you look at the
proposed Class Structure for Collections drafted by J4 (Standards) - you
are SOL. Just don't hold your breath that this structure will be
expanded any time soon.
Jimmy
|