:> 运算符在 F# 中有什么作用?

What does the :> operator do in F#?

:> 运算符在 F# 中有什么作用?

例如

myFunction x :> System.Object

它将类型转换为层次结构中更高的类型。所以它是一个转换运算符。

参见以下示例(也取自 here 和之前的定义):

type Base1() =
    abstract member F : unit -> unit
    default u.F() =
     printfn "F Base1"

type Derived1() =
    inherit Base1()
    override u.F() =
      printfn "F Derived1"


let d1 : Derived1 = Derived1()

// Upcast to Base1.
let base1 = d1 :> Base1

将类型转换为层次结构中较高的类型。
资料来源:https://msdn.microsoft.com/en-us/library/dd233228.aspx

--
就像将实体类型转换为玩家类型一样。