The code works if you call a function or assign a value within the try-catch
block:
module public test
open System
let testing =
let divide = fun a b -> a / b
try
divide 100 0
with
| :? System.DivideByZeroException as ex -> printfn "Exception! %s (ex.Message); None.Value
or
module public test
open System
let testing =
let divide = fun a b -> a / b
let mutable num = divide 100 10
try
num = divide 100 0
with
| :? System.DivideByZeroException as ex -> printfn "Exception! %s (ex.Message); None.Value
When declaring a name inside the block, it does not leave me:
module public test
open System
let testing =
/*
El bloque que sigue a este objeto 'let' está sin finalizar. Cada bloque de
código es una expresión y debe tener un resultado. 'let' no puede ser el
elemento de código final en un bloque. Considere la posibilidad de asignar a
este bloque un resultado explícito.
*/
let divide = fun a b -> a / b
try
let num = 100
let num2 = 20
divide num num2
with
| :? System.DivideByZeroException as ex -> printfn "Exception! %s (ex.Message); None.Value