Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template toOption*[T](expr: T; ex: untyped): Option[T] =
- block:
- var res: Option[T]
- try:
- res = some(expr)
- except ex:
- res = none(T)
- res
- let x = toOption(parseInt("3"), ValueError) # line(17): cannot instantiate Option got: <int> but expected: <T>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement