Reference Cell

Create a new reference cell

1: 
2: 
let refVar = ref 1
refVar := 2 // Value changed to 2

Set and get value (property)

1: 
2: 
refVar.Value <- 3
printfn "Value using Value property: %d" refVar.Value

Set and get value (record field) for ML compatibility

1: 
2: 
3: 
4: 
refVar.contents <- 4
printfn "Value using contents: %d" refVar.contents

printfn "Value using `!` dereference operator: %d" !refVar