Guest User

Untitled

a guest
Dec 24th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.30 KB | None | 0 0
  1. type Either[A, B] = object
  2.   a:   A
  3.   b:   B
  4.   isA: bool
  5.  
  6. proc test(input: string): Either[string, int] =
  7.   if blahblahblah:
  8.     return Either[string, int](a: input, isA: true)
  9.   return Either[string, int](b: 123)
  10.  
  11. let out = test("Test")
  12. if out.isAl:
  13.   let str = out.a
  14. else:
  15.   let num = out.b
Advertisement
Add Comment
Please, Sign In to add comment