nim-theNewWeb/test/oop_example2.nim

26 lines
438 B
Nim
Raw Normal View History

type
Node = ref object of RootObj
value: string
active: bool
type
NumNode = ref object of Node
type
BinOp = ref object of Node
left, op, right: string
var numnum = NumNode(value: "3", active: true)
echo numnum[]
# > (value: "3", active: true)
var add = BinOp(
left: "7",
op: "+",
right: "9",
active: true
)
echo add[]
# > (left: "7", op: "+", right: "9", value: "", active: true))