AA key conversion woes

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Apr 17 11:48:04 PDT 2012


On 4/17/12, Andrej Mitrovic <andrej.mitrovich at gmail.com> wrote:
> On 4/17/12, H. S. Teoh <hsteoh at quickfur.ath.cx> wrote:
>> But even then, I'm considering if .keys should return a mutable array if
>> the key is a value type
>
> How about having .keys for mutable

Personally I use .keys often and expect them to be mutable. For example:

string[] atts = attributes.keys;
sort(atts);

There is no "sorted" in phobos so I have to use the sort function
which takes arguments by reference. I can't pass immutable arrays to
it.

Sometimes I like to store an array of keys from multiple hashes, e.g.:
string[] arr = hash.keys;
arr ~= hash2.keys;

Long story short, making .keys immutable would break a lot of my code.
I don't know if that's true for others as well..


More information about the Digitalmars-d mailing list