I need to declare a function in F# that takes 2 parameters (row, col) and return an 2-dimensional array of Option (intitializing all elements to be none), but I don’t know the right syntax. I’ve tried something like:
type T =
{
....//my type
}
let create2DArrayOfT (row : int , col: int) Array2D<Option<T>> = Array2D.init<Option<T>> 10 10 (fun -> None)
the signature above is wrong in specifing the return type.
So I have 2 questions:
- What’s the right signature for specifying the return type as a 2-dimensional array?
- I’ve tought to use Option for the elements of my array because I want it to allow some locations to be empty. Is this reasonable?
You don’t need to specify return type as that will be deduced by type inference.
Just use:
UPDATE:
If you want specify return type use: