Skip to content

Commit

Permalink
spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Roddie committed Oct 18, 2023
1 parent 748be42 commit 6684d3f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/fsharp-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ The `failwith` function throws an exception of type `Exception`.
let divideFailwith x y =
if y = 0 then
failwith "Divisor cannot be zero."
else x / y
else x / y

Exception handling is done via `try/with` expressions.

let divide x y =
try
Some (x / y)
with :? System.DivideByZeroException ->
printfn "Division by zero!"
printfn "Division by zero!"
None

The `try/finally` expression enables you to execute clean-up code even if a block of code throws an exception. Here's an example which also defines custom exceptions.
Expand Down

0 comments on commit 6684d3f

Please sign in to comment.