如何用unit()包装OCaml表达式?

Jam*_*hra 2 ocaml

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 = ()
Run Code Online (Sandbox Code Playgroud)

如何使用分号运算符使非unit表达式(如3)返回unit工作?

Jef*_*eld 5

ignore为此有一个功能。

# ignore 3; ();;
- : unit = ()
#
Run Code Online (Sandbox Code Playgroud)