Testing for null reference in F#

后端 未结 3 857
渐次进展
渐次进展 2020-12-17 15:56

Given the following:

[]
type TweetUser = {
    [] Followers:int
    [

        
3条回答
  •  醉话见心
    2020-12-17 16:42

    Though this question is old, I didn't see any examples of boxing to solve the problem. In cases where my presenter does not allow null literals, but may be set from a view, I prefer to use boxing.

    isNull <| box obj
    

    or

    let isMyObjNull = isNull <| box obj
    

    or

    match box obj with
    | null -> (* obj is null *)
    | _ -> (* obj is not null *)
    

提交回复
热议问题