在 F# 中不可能为结构体元组定义类型别名。只有通过解决方法,它才有效。
let x = struct (1, 2)
> val x : struct (int * int) = struct (1, 2)
let y : struct (int * int) = struct (4, 5) // explicit type
> val y : struct (int * int) = struct (4, 5)
type S = struct (int * int) // straight definition
> error FS0010: Unexpected symbol '(' in member definition
type S = ValueTuple<int, int> // workaround
> [<Struct>]
type S = struct (int * int)
Run Code Online (Sandbox Code Playgroud)
“type S = struct (int * int)”的错误是编译器错误吗?
尝试提交错误并在这里找到答案:https ://github.com/dotnet/fsharp/issues/7014
类型周围需要括号:
type Alias = (struct(int * int))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
276 次 |
最近记录: |