Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# Private Static Methods

How do i define a private static method in a class in f#? when i try to attach a private modifier it complains.

like image 487
RCIX Avatar asked Jun 20 '09 02:06

RCIX


2 Answers

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()
like image 184
Ray Vernagus Avatar answered Oct 09 '22 00:10

Ray Vernagus


An alternative:

type MyClass () =
    static let myPrivateMethod () =
        printfn "This is inaccessible outside the class."
like image 23
MiloDC Avatar answered Oct 08 '22 23:10

MiloDC