f# - Failed attempt to define a record type in F#
问题描述
I tried to define a F# record. This does not work for me. Any idea? Below I used the interactive mode in Visual Studio.
{x : int};;
Stopped due to error
System.Exception: Operation could not be completed due to earlier error
Unexpected symbol ':' in expression. Expected '}' or other token. at 0,3
Unmatched '{' at 0,0
Unexpected symbol ':' in expression. Expected '}' or other token. at 0,3
Unmatched '{' at 0,0
Invalid object, sequence or record expression at 0,0
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }' at 0,0
Invalid object, sequence or record expression at 0,0
Invalid record, sequence or computation expression. Sequence expressions should be of the form 'seq { ... }' at 0,0
解决方案
您的类型定义似乎缺少一些东西。类型定义以关键字开头type
。
这定义了一个类型并打印它的一个实例:
type test = {x:int} // definition
printf "%A" {x = 1} // example use
在此处查看实际操作:https ://dotnetfiddle.net/Fb0wi5
推荐阅读
- php - PHP - 将“非”UTF-8 转换为 UTF-8
- java - 这是使用 if 语句处理不同任务的好方法吗?
- react-native - onViewableItemsChanged 未在嵌套的 ScrollView 中调用(React-Native)
- python - 配置 PunktSentenceTokenizer 并指定语言
- c# - C#获取构建中使用的浮动版本包的具体版本
- javascript - 如何等待 onChange 事件使用反应钩子设置值?
- c# - 使用 heap.EnumerateRoots() 找不到带有 ClrMD 的实例保留路径
- python - 无需登录/通过 FastApi 的 OAuth2
- excel - 在数据透视表 excel 2019 中没有一对多的工作关系
- vba - 微软 Office 365 展望。如何更改团队-会议加入链接