这是否意味着每当我传递一个不可为空类型的数组时,我仍然应该检查它是否为空?实际上它甚至不可能检查<> null
但必须使用operator.unchecked
。它比 C# 更好吗?
type test=
{
value: int
}
let solution = Array.zeroCreate 10
solution.[0] <- {value = 1}
solution.[1].value // System.NullReferenceException: Object reference not set to an instance of an object
type test =
{value: int;}
val solution : test [] =
[|{value = 1;}; null; null; null; null; null; null; null; null; null|]
val it : unit = ()