Sorry, I just love templates, AAs and mixins :)
grauzone
none at example.net
Sat Oct 17 10:32:00 PDT 2009
Saaa wrote:
> public void addToAA(char[] var_name, KT, ET)(KT key, ET element)
> {
> mixin(ET.stringof~`[]* elements = key in `~var_name~`;`);
> if( elements == null )
> {
> ET[] temp;
> temp.length = 1;
> temp[0] = element;
> mixin(var_name~`[key] = temp;`);
> }
> else
> {
> (*elements).length = (*elements).length + 1;
> (*elements)[(*elements).length-1] = element;
> }
> }
>
>
It's unreadable. What the hell does it do? How do you use it?
It's a good example how you can write-only code in D.
More information about the Digitalmars-d-learn
mailing list