Is there a way to override System.Object‘s virtual methods, particularly ToString, when creating an interface type using an object expression?
type INamedObject =
abstract Name : string
let makeNamedObject name =
{ new INamedObject with
member x.Name = name
override x.ToString() = x.Name } //would like to do this, but doesn't work
It’s possible to supplly multiple types to implement / override in an object expression including concrete types. This allows you to both specify
ObjectandINamedObjectin the expression and get the desired effect.