我正在尝试编写一个自定义DivideByInt,如下所示
type Pair = Pair of int * int with
static member DivideByInt pair int = pair
[<EntryPoint>]
let main argv =
LanguagePrimitives.DivideByInt (Pair(1,2)) 1
|> ignore
0
// compiler error: "FS0001: Method or object constructor 'DivideByInt' not found"
Run Code Online (Sandbox Code Playgroud)
为什么编译器找不到Pair.DivideByInt?
Pair.DivideByInt 必须以元组作为输入
更正后的版本:
type Pair = Pair of int * int with
static member DivideByInt (pair, int) = pair
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88 次 |
| 最近记录: |