看到记录已经为其字段设置了公共Getter /(Setter),是否可以指定记录满足匹配的接口而无需重新实现它?
例如:
type IText =
abstract text : string with get,set
type TextRec =
{
mutable text : string
}
Run Code Online (Sandbox Code Playgroud)
现在看到Record已经隐式实现了这个接口,我想在记录中放置一个"继承IText"或"接口IText"(没有正文),但看起来我不能这样做.实际上,我相信我必须通过将其添加到记录中来重新实现接口:
interface IText with
member this.text
with get() = this.text
and set(v) = this.text <- v
Run Code Online (Sandbox Code Playgroud)
谢谢