consider the follwoing:

import tango.io.Stdout, tango.io.Path, tango.text.Util;
import std.algorithm, std.string , std.stdio, std.array, std.conv, std.regex, std.typecons;

//i know al imports are not necessary for this example, just ^c^v from my actual code

alias string[] surSegments


void makeHashmap(T,R)(T[] plainArr, string hashes, out R[] hashMap)
{
        //first split the hashes
        string [] hashesArr = std.algorithm.splitter(hashes, ',').array;
        
        for(int i = 0; i < plainArr.length; i++)
        {
                R hashElement;
                for(int j = 0; j < hashesArr.length; j++)
                {
                        hashElement[hashesArr[j]] =  = plainArr[i][j];
                }
                hashMap ~= hashElement;
        }
        
}


void main()
{

surSegments[] s = [[a,b,c,d], [e,f,g,h]];
h = "1,2,3,4";
surSegments[string][] ss;

makeHashmap(s, h, ss);


}

i expect ss to look like :
[
[1 => a, 2 => b, 3 => c, 4 => d],
[1 => e, 2 => f, 3 => g, 4 => h]
]

etc.

instead i get compilation error:
Error: cannot implicitly convert expression (hashesArr[cast(ulong)j]) of type string to string[]


isn't hashElement of type surSegment[string] and hashElement[somestring] of type string, just like plainArr[i][j] ??

Reply via email to