Created
March 11, 2013 22:03
-
-
Save gradha/5138245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type | |
TKind1 = enum TK1A, TK1B | |
TKind2 = enum TK2A, TK2B | |
TKind3 = enum TK3A, TK3B | |
TK2 = object | |
case kind: TKind2 | |
of TK2A: tk2_int: int | |
of TK2B: tk2_string: string | |
TK3 = object | |
case kind: TKind3 | |
of TK3A: tk3_int: int | |
of TK3B: tk3_string: string | |
TK1 = object | |
case kind: TKind1 | |
of TK1A: | |
root1: int | |
suba: TK2 | |
of TK1B: | |
root2: string | |
subb: TK3 | |
when isMainModule: | |
var test1, test2, test3, test4: TK1 | |
test1.kind = TK1A | |
test1.suba.kind = TK2A | |
test1.suba.tk2_int = 3 | |
test2.kind = TK1A | |
test2.suba.kind = TK2B | |
test2.suba.tk2_string = "3" | |
test3.kind = TK1B | |
test3.subb.kind = TK3A | |
test3.subb.tk3_int = 3 | |
test4.kind = TK1B | |
test4.subb.kind = TK3B | |
test4.subb.tk3_string = "3" | |
echo repr(test1) | |
echo repr(test2) | |
echo repr(test3) | |
echo repr(test4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment