I am trying to create a type which is basically an Array with additional 
information. I want to use only [int | float] for the Array.
    
    
    type
      MyArray* = ref object
        length*: int
        index: int
        arr: seq[int|float]
    
    proc createMyArray(length: int, tp: string): MyArray =
      if tp == "int":
        let ttype = int
      elif tp == "float":
        let ttype = float
      result = MyArray(
        length: length,
        index: 0,
        arr: newSeq(ttype)[length]
      )
    
    var ma = createMyArray(int(rows), "float")
    
    
    Run

The code is probably naive as I am still learning. The MyArray type compiles if 
everything below is commented out. As soon as I uncomment, it gives me this 
error.
    
    
    /home/jimmie/Dev/Nim/ntplayground.nim(125, 19) Error: invalid type: 'int or 
float' in this context: 'proc (length: int, tp: string): MyArray' for proc
    
    
    
    Run

Any help, wisdom or understanding greatly appreciated. 

Reply via email to