Why '&&' and not '&'?

前端 未结 16 1511
别跟我提以往
别跟我提以往 2020-11-27 12:11

Why is && preferable to & and || preferable to |?

I asked someone who\'s been programming for years a

16条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 12:55

    It's important, because if the cost of evaluation of bool2 (for instance) is high but bool1 is false, then you've saved yourself a fair bit of computation by using && over &

提交回复
热议问题