I’m trying to create a class with a list of int as member variable. However, it is not working as expected. See this example:
open System.Collections.Generic
type Class() =
member this.x = List()
member this.y = 1
let c = Class()
printfn "%d" c.y
c.x.Add(1)
printfn "%d" c.x.[0]
This is printing 1 and then throws ArgumentOutOfRangeException because the list is empty.
Would be grateful for an explanation
Thanks!