In OCaml, there cannot be an uninitialized array. But look at it like this: you will never have a hard error in your program caused by uninitialized values.
If the values ββthat you ultimately want to place in your array are not yet available, are you probably creating the array too soon? Consider using Array.init to create it at the moment the necessary inputs are available, without creating it earlier and leaving it temporarily uninitialized.
The Array.init function takes an argument as a function that it uses to calculate the initial value of each cell.
source share