F# record member evaluation

f#, member, record

Solution

It's a property; you're basically calling the `get_b()` member.

If you want the effect to happen once with the constructor, you could use a class:

type Test(a:float) =
    // constructor
    let b =   // compute it once, store it in a field in the class
        printfn "oh no"
        a * 2.
    // properties
    member this.A = a
    member this.B = b

Problem

Why is t.b evaluated on every call? And is there any way how to make it evaluate only once? ``` type test = { a: float } member x.b = printfn "oh no" x.a * 2. let t = { a = 1. } t.b t.b ```

Original source