use `when` , as long the variable can be know at compile time
    
    
    import typetraits
    
    const flag = true
    when flag == true:
      var c = 5
    else:
      var c = 10.0
    
    echo name(type(c))
    

take a note that's only for compile time, you cannot switch during runtime

Reply via email to