Question

Is there a way to have a mutable static variable in F# class that is identical to a static variable in C# class ?

Was it helpful?

Solution

You use static let bindings (note: while necessary some times, it's none too functional):

type StaticMemberTest () =

    static let mutable test : string = ""

    member this.Test 

        with get() = 
            test <- "asdf"
            test
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top