Is it possible to provide an implementation for the C# equality (==) operator in F#?
EDIT:
This code:
static member (=) (left : Foo, right : Foo) =
Produces the compiler warning:
The name '(=)' should not be used as a member name. To define equality semantics for a type, override the 'Object.Equals' member. If defining a static member for use from other CLI languages then use the name 'op_Equality' instead.
The latter part addresses what I was trying to do. Any idea why op_Equality
is favored over simply (=)
?
Figured it out:
type Foo() =
static member op_Equality (left : Foo, right : Foo) =
Are you looking for operator overloading in F#?
The different operators are defined in CIL, so overloading loading an operator in F# would overload it in C#, VB.NET and any other .NET language that supports that operator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With