Why don't we have two nulls?

后端 未结 27 1456
孤独总比滥情好
孤独总比滥情好 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:46

    In most programming languages null means "empty" or "undefined". "Unknown" on the other hand is something different. In essence "unknown" describes the state of the object. This state must have come from somewhere in your program.

    Have a look at the Null Object pattern. It may help you with what you are trying to achieve.

提交回复
热议问题