How do i define a private static method in a class in f#? when i try to attach a private modifier it complains.
Here's a short script that defines and uses a private static member:
type MyClass =
static member private MyPrivateMember() = printfn "MyPrivateMember()"
static member MyMember() = MyClass.MyPrivateMember()
MyClass.MyMember() // MyPrivateMember()
An alternative:
type MyClass () =
static let myPrivateMethod () =
printfn "This is inaccessible outside the class."
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