In F#, many infix operators can be made prefix operators:
a + b
(+) 1 a b
However, this doesn't seem to be allowed for the upcast (or downcast) operators.
x
is a UserPrincipal
, which inherits from Principal
x :> Principal
(:>) x Principal
Why?
Probably because unlike other operators, the cast operators don't take two expressions as arguments; they take an expression and a type. So (:>) x
would have to be "a function that takes a type", which is not a thing that exists in F#.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.