Skip to content

Commit 00b774a

Browse files
bobbypriamchenglou
authored andcommitted
Fix Exception.md example type error (#212)
* Fix Exception.md example type error * Update exception.md
1 parent 2bc4987 commit 00b774a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/pages/guide/language/exception.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ let getItem theList => {
1717
};
1818
1919
let result = try (getItem [1, 2, 3]) {
20-
| Not_found => print_endline "Item not found!"
20+
| Not_found => 0 /* Default value if getItem throws */
2121
};
2222
```
2323

24+
Note that the above is just for demonstration purposes; in reality, you'd return an `option int` directly from `getItem` and avoid the `try` altogether.
25+
2426
You can directly match on exceptions _while_ getting another return value from a function:
2527

2628
```reason

0 commit comments

Comments
 (0)