I discovered this odd(well odd for me) feature while creating array with references.
If I create an array:
let arr = Array.make 81 (ref 0)
and then get and set the first element:
let r = Array.get arr 0
let () = r := 4143
I now set all the references in arr to 4143
If I instead create an array:
let arr2 = Array.init 81 (fun _ -> ref 0)
and then get and set the first element:
let r2 = Array.get arr2 0
let () = r2 := 4143
Now only the first reference is set to 4143…
Why does this behavior exist?