【发布时间】:2019-10-13 23:37:08
【问题描述】:
我是 Ocaml 的初学者,我似乎无法理解这种语法。 我必须编写一个不返回布尔值否定的函数。
这是我写的:
let not x =
match x with
true -> false
| false -> true;
if (not false) then Printf.printf "True !"
但它拒绝编译,谁能给我一个提示?
错误信息是:
Error: This expression has type unit but an expression was expected of type bool
在最后一行。
【问题讨论】:
-
尝试使用两个分号来关闭
not声明? -
天哪!谢谢 !我如何在你的答案上加上绿旗?
-
这只是一个猜测,所以我发表了评论。现在我还创建了一个您可以接受的答案
标签: syntax compiler-errors ocaml