I have the following code:
    
    
    type
        boolPointer = ptr bool
        stringPointer = ptr string
        
        Node = ref object of RootObj
            Values* : Table[string, pointer]
            Map : Table[string, string]
     
     proc `[]`(parser : ArgParser, key : string): bool|string =
         if parser.Values.hasKey(key):
            
            if parser.Values[key] is boolPointer:
                 result = cast[ptr bool](parser.Values[key])[]
            elif parser.Values[key] is stringPointer:
                result = cast[ptr string](parser.Values[key])[]

But this doesn't compile: Error: type mismatch: got <string> but expected 'bool'

The error takes place on the second cast and I tried using generics and the any 
keyword for the return type and it is still failing... Any ideas?

Reply via email to