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 –