Defining double exclamation?

前端 未结 7 1942
失恋的感觉
失恋的感觉 2021-02-04 06:43

I understand what a double exclamation mark does (or I think I understand) but I am not sure how it is defined on a random object. For example in the code snippet below:

7条回答
  •  既然无缘
    2021-02-04 07:09

    The easiest way to remember double-negation !!a is to narrow a!=0 to 1 and a==0 to 0. Which is in boolean context (i.e. C++) true or false.

提交回复
热议问题