I am struggling with the concept of TaintedString in nim. I have scoured the 
forum and google but am finding very little.

This code works fine: 
    
    
    import strutils
    
    var
        inMod = false
        texts = newSeq[string]()
        s = ""
    
    for line in lines  r"../data/modules1.fhx":
        if line.startsWith("MODULE_INSTANCE TAG="):
            s = newStringOfCap(10000)
            s.add(line & "\n")
            inMod = true
        elif inMod:
            s.add(line & "\n")
            if line.startsWith("}"):
                inMod = false
                texts.add(s)
    
    echo texts.len
    
    
    Run

But this code has error: 
    
    
    import strutils
    import sequtils
    
    var
        inMod = false
        texts = newSeqWith(1400, string)
        s = ""
    
    for line in lines  r"../data/modules1.fhx":
        if line.startsWith("MODULE_INSTANCE TAG="):
            s = newStringOfCap(10000)
            s.add(line & "\n")
            inMod = true
        elif inMod:
            s.add(line & "\n")
            if line.startsWith("}"):
                inMod = false
                texts.add(s)
    
    echo texts.len
    
    
    Run

The newSeqWith line has the following error: `Error: type mismatch: got <type 
string> but expected 'TaintedString = string'`

Please advise.

Reply via email to