我正在尝试编写一个自定义 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"
为什么编译器找不到 Pair.DivideByInt?
请您参考如下方法:
Pair.DivideByInt
必须采用元组作为输入
更正后的版本:
type Pair = Pair of int * int with
static member DivideByInt (pair, int) = pair