Use of "T"

solidstate1991 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 12 15:56:25 PDT 2017


On Wednesday, 12 April 2017 at 16:05:23 UTC, XavierAP wrote:
> On Wednesday, 12 April 2017 at 14:46:20 UTC, solidstate1991 
> wrote:

>
> T is just the common name of a (type) parameter, mostly 
> whenever the template is more generic that you can't think of a 
> more informative (template) parameter name. Just like you could 
> use "str" for a string or "i" for an int name. But in you case 
> you could use a more informative name such as "keyType" since 
> you are describing keyType -> valueType dictionaries, also 
> called associative arrays.
>
> Moreover these dictionaries are built-in basic types in D:
> https://dlang.org/spec/hash-map.html
>

>
> So according to the spec linked above, those examples would be 
> declared:
>
> string[int] dict1;
> string[string] dict2;
> int[string] dict3;

I know the existence of those and I'm frequently using them, 
however I need a two-way one. (Might be using two hash-tables 
instead if I can't find a better solution)


More information about the Digitalmars-d-learn mailing list