Use when not if (the type must know by compiler at compile time, not run time):
proc makeFont3(fontMessage: int|wFont): wFont {.discardable.}=
var
fontTmpMessage: wFont = Font(12, weight=wFontWeightBold)
when (fontMessage is float) or (fontMessage is int) :
fontTmpMessage = Font(float fontMessage, weight=wFontWeightBold)
else:
fontTmpMessage = fontMessage
return fontTmpMessage
Run
- maybe this dynamic try is not possible? oyster
- Re: maybe this dynamic try is not possible? Ward
