|
|
|
|
|
by kragen
5854 days ago
|
|
OCaml does warn you: : kragen@inexorable:~/mail ; ocaml
Objective Caml version 3.10.2
# let divide x = function 0 -> None | y -> Some (x / y) ;;
val divide : int -> int -> int option = <fun>
# let printResult = function Some x -> print_int x ;;
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
None
val printResult : int option -> unit = <fun>
# printResult (divide 9 3) ;;
3- : unit = ()
# printResult (divide 10 0) ;;
Exception: Match_failure ("", 1, 18).
#
|
|