Hi all,

I have a Something which takes a specialised thing. I then have a bunch of 
types that are specialised Something`s. I then want a proc which will return 
any of the `SpecialisedSomethings.

Code will make it really clear (please forgive syntax errors): 
    
    
    type
      Something[T] = object
        a: int
        special: T
      
      SpecialisedTA = object
        c: int
      SpecialisedA = Something[SpecialisedTA]
      
      SpecialisedTB = object
        d: int
      SpecialisedB = Something[SpecialisedTB]
    
    proc doIt(strategy: int): Something =
      if (...):
        result = SpecialisedTA(a = 10, c = 30)
      else:
        result = SpecialisedTB(a = 10, d = 10)
    
    let myThing = doIt(...)
    
    
    Run

The problem is that the proc definition and the let myThing... don't compile 
(and of course, this is all numpty code to focus on the problem ;-)).

I _[think](https://forum.nim-lang.org/postActivity.xml#think) the answer is in 
[https://nim-lang.org/docs/manual.html#type-relations-subtype-relation](https://nim-lang.org/docs/manual.html#type-relations-subtype-relation),
 and I know when it clicks I will kick myself, but I just can't figure it out.

What am I missing?

Thanks!

Reply via email to