1
說我有它定義兩個函數,Function1
和Function2
和我使用對象表達式來實現它的接口ICache
,但我也希望添加一個輔助函數:F#添加非接口功能到對象表達式
let WebCache =
{ new ICache with
member __.HelperFunction = //this doesn't work!
member __.Function1 = foo
member __.Function2 = bar
}
F#似乎不允許你添加任何不屬於界面的方法。有沒有解決方法?如果我想這樣做,我是不是應該首先使用對象表達式?
啊哈,就這麼簡單!謝謝。 – jackmott