这两个 F# 类型函数有什么区别:
let defaultInstance1<'a when 'a:(new: unit->'a)> = new 'a()
[<GeneralizableValue>]
let defaultInstance2<'a when 'a:(new: unit->'a)> = new 'a()
这是一个很好的博客:
http://blogs.msdn.com/b/mulambda/archive/2010/05/01/value-restriction-in-f.aspx http://blogs.msdn.com/b/mulambda/archive/2010/05/01/value-restriction-in-f.aspx(已存档here https://web.archive.org/web/20160313200648/http://blogs.msdn.com/b/mulambda/archive/2010/05/01/value-restriction-in-f.aspx).
需要一些阅读才能到达GeneralizableValue
部分,但如果你到达那里,我想你会理解的。 :)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)