以下表达式 3 ; utop 中的 ()
会产生以下响应
utop # 3 ; ();;
Characters 0-1:
Warning 10: this expression should have type unit.
Characters 0-1:
Warning 10: this expression should have type unit.
- : unit = ()
如何使非 unit
表达式(例如 3
)返回 unit
来与分号运算符一起使用?
最佳答案
有一个函数ignore
就是为了这个目的。
# ignore 3; ();;
- : unit = ()
#
关于ocaml - 如何用unit()包装OCaml表达式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55424742/