Why does Objective-C use YES/NO macro convention instead of true/false?

后端 未结 5 1264
礼貌的吻别
礼貌的吻别 2020-12-30 01:54

Most languages use the true/false keywords for boolean values. I found that even Smalltalk is using true/false. I know Objective-C is just borrow

5条回答
  •  爱一瞬间的悲伤
    2020-12-30 02:40

    Objective-C is a very verbose language, all methods are very descriptive, and using YES/NO for boolean values instead of true/false makes it more human readable.

    You would probably find the following conversation strange, if it happened in real life: A: "Did you see the movie?" B: "True"

    If B had answered "yes" (or "no"), it would sound perfectly normal, and code looks more like plain english by using YES/NO instead of true/false.

提交回复
热议问题