Nic*_*ner 5 syntax error-handling ocaml
以下是可能的吗?
try
(* danger zone *)
with Not_found e ->
(* code to handle not found *)
with t ->
(* code to handle all other issues *)
Run Code Online (Sandbox Code Playgroud)
如果我在顶层键入它,我会在第二个上遇到语法错误with.也许有一些我不知道的语法?
首选前置另一个try匹配的方法是with什么?
Jef*_*eld 13
该with部分是一系列模式,因此您可以按如下方式编写:
try
(* dangerous code area *)
with
| Not_found -> (* Not found handling code *)
| t -> (* Handle other issues here *)
Run Code Online (Sandbox Code Playgroud)