3
在case語句結尾處實現通配符意味着什麼?向_通配符上傳值的含義是什麼?
採取以下語法:
match imp req with
| Success () -> this.Ok () :> _
這是一樣的:
| Success () -> this.Ok () :> IHttpActionResult
什麼是寫這種類型的語法的優勢在哪裏?
這裏是我的問題的情況下:
type PushController (imp) =
inherit ApiController ()
member this.Post (portalId : string, req : PushRequestDtr) : IHttpActionResult =
match imp req with
| Success () -> this.Ok () :> _
| Failure (ValidationFailure msg) -> this.BadRequest msg :> _
| Failure (IntegrationFailure msg) ->
this.InternalServerError (InvalidOperationException msg) :> _
這不是一個通配符,你只是讓編譯器推斷類型轉換爲你基礎上,'後'你提供的簽名。 – nphx
噢...那麼推斷的簽名所需的返回類型是什麼? –
相關:http://stackoverflow.com/questions/3532637/type-mismatch-error-f-type-inference-fail –