【发布时间】:2017-04-07 17:50:29
【问题描述】:
例如,如果我尝试扩展int,而int 不是类型的真实名称,则此代码将失败:
type int with
member this.IsEven = this % 2 = 0
我必须改用System.Int32:
type System.Int32 with
member this.IsEven = this % 2 = 0
//test
let i = 20
if i.IsEven then printfn "'%i' is even" i
为什么我不能使用类型缩写int?
【问题讨论】:
-
因为你不能。因为他们不是那样写的。因为。
标签: .net casting f# functional-programming language-design