ocaml - 如何用 unit() 包装 OCaml 表达式?
问题描述
utop 中的以下表达式3 ; ()
导致以下响应
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 = ()
#
推荐阅读
- javascript - 单击以在具有多个位置的多个 hml 文件上显示电话号码
- android - 垂直多线芯片组是否有可能每条线有一个芯片?
- php - 自定义类别 URL wordpress
- php - 如何用更少的代码行编写下面的 switch case?
- django - 删除另一个选项卡中的相关内联记录时出现 MultiValueDictKeyError
- android - 从命令行或 Espresso 测试用例的开发人员选项中启用“不保留活动”
- javascript - 如何阻止 Discord 机器人响应其他机器人?
- python - 在 Python 中使用 Requests 模块时遇到问题
- ios - 为什么在覆盖自定义单元格的 setSelected 方法后,表格视图单元格每次在滚动时出现时都会被选中?
- swift - 无法转换“MyEnum”类型的值
' 到预期的参数类型 'MyEnum<_>'