I am writing an F# type, and I'm having trouble figuring out how to reference a member function from the constructor upon initialization. I think I'm supposed to use a do binding, but then the do binding can't understand the member functions. Is there no way around this?
You can do it this way:
type MyClass() as this = // Note as this
do this.SayHello()
member this.SayHello() =
do printfn "Hello from constructor!"
But generally it is not a good practice
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