Why don't we have two nulls?

后端 未结 27 1099
孤独总比滥情好
孤独总比滥情好 2021-02-02 08:38

I\'ve often wondered why languages with a null representing \"no value\" don\'t differentiate between the passive \"I don\'t know what the value is\"

27条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-02 08:53

    It's been tried: Visual Basic 6 had Nothing, Null, and Empty. And it led to such poor code, it featured at #12 in the legendary Thirteen Ways to Loathe VB article in Dr Dobbs.

    Use the Null Object pattern instead, as others have suggested.

提交回复
热议问题