2016-03-12 155 views
2

的F#轉發是否有可能轉發可選參數e.g:可選參數

type Type() = 
    member this.A(?param) = printfn "%d" <| defaultArg param 0 
    member this.B(?param) = this.A(param) // how to do this ? 

回答

3

像這樣:

member this.B(?param) = this.A(?param = param) 

使用?提供了一個名爲可選參數允許你傳遞一個選項時。