Try expression

Try can also be used as an expression; the type of the try branch then needs to fit the types of except branches, but the type of the finally branch always has to be void:

  1. from strutils import parseInt
  2. let x = try: parseInt("133a")
  3. except: -1
  4. finally: echo "hi"

To prevent confusing code there is a parsing limitation; if the try follows a ( it has to be written as a one liner:

  1. let x = (try: parseInt("133a") except: -1)