Hi, I'm trying to use Nim in order to create a variable of a certain type in 
dependence of a certain input. I'm using the following part of code:
    
    
    type Uno = object of RootObj
        x: float
    
    type Due = object of Uno
    type Tre = object of Uno
        y: float
    
    proc newDue(x: float): Due {.inline.} = Due(x: x)
    proc newTre(x, y: float): Tre {.inline.} = Tre(x: x, y:y)
    
    var appo = 1.2
    var caz = (if appo>1: newTre(0.5, 2.0) else: newDue(1.0))
    echo caz
    
    
    Run

I don't get why, when i print caz content, it just gives the following output: 
(x: 0.5)

I would expect to obtain also a y value, considering that Tre type has x, y 
labeled data member. What am i missing? Thanks

Reply via email to