Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of the F# :> operator

Tags:

f#

I have seen some code using the :> operator to accomplish something similar to type-casting in C# but even though I've searched a lot online I've seen no documentation about it.

What is that operator used for?

How does it work?

Where can I find some documentation about it?

like image 269
Luiso Avatar asked Dec 03 '22 14:12

Luiso


1 Answers

:> is the upcast operator. It's used to cast upward in an hierarchy so it's a type of casting that can be verified at compile time.

Its counterpart :?> is the downcast operator but the success of this can only be resolved at runtime.

See this page for more details: https://msdn.microsoft.com/visualfsharpdocs/conceptual/casting-and-conversions-[fsharp]

like image 119
TheInnerLight Avatar answered Jan 07 '23 22:01

TheInnerLight