Is it possible for an object to refer to itself before member definitions? Something like this:
type public ClassA () = class
let b = new ClassB(this)
member public x.getClassB() = b
end
where 'this' is a reference to the instance of ClassA creating the ClassB?
Classes can refer to themselves in their constructors using as
:
type public ClassA () as this =
let b = new ClassB(this)
member public x.getClassB() = b
and public ClassB (a: ClassA) =
member public x.getClassA() = a
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