Well, "the above code" from alehander42 is Nim's usual way to go about object 
variants and the code you don't like is the usual way to go about "methods" of 
object variants. You might want to write `result = ...` instead of `return ...`.
    
    
    proc addTwo(self: C): int =
       case self.kind
       of int: result = self.num + 2
       of string: result = 10_000_000
       else: {.fatal: "Meh, illegal case in addProc" .}
    
    Run

Reply via email to