Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type Either[A, B] = object
- a: A
- b: B
- isA: bool
- proc test(input: string): Either[string, int] =
- if blahblahblah:
- return Either[string, int](a: input, isA: true)
- return Either[string, int](b: 123)
- let out = test("Test")
- if out.isAl:
- let str = out.a
- else:
- let num = out.b
Advertisement
Add Comment
Please, Sign In to add comment