Reputation: 6626
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?
Upvotes: 11
Views: 1420
Reputation: 4280
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
Upvotes: 16