Re: [閒聊] 真的有扯到...
: The parts of an expression containing && or || operators are evaluated only
: until it’s known whether the condition is true or false. Thus, evaluation
: of the express
: ( gender == FEMALE ) && ( age >= 65 )
: stops immediately if gender is not equal to FEMALE (i.e., the entire
: expression is false) and continues if gender is equal to FEMALE (i.e.,
: the entire expression could still be true if the condition age >= 65 is true).
: This feature of conditional AND and conditional OR expressions is called s
: hort-circuit evaluation.
: ※ 編輯: icecastleo 來自: 111.243.0.134 (03/28 20:51)
|| 如果前者為真,可以省略後算,直接回傳為真
&& 如果前者為偽,可以省略後算,直接回傳為偽
請搞清楚邏輯關係...
相反的 || 如果前者為偽,絕對不是像我同事說的,回傳為偽,省略後算
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.5.247
→
03/28 21:03, , 1F
03/28 21:03, 1F
※ 編輯: erspicu 來自: 219.70.5.247 (03/28 21:03)
推
03/28 21:06, , 2F
03/28 21:06, 2F
→
03/28 21:07, , 3F
03/28 21:07, 3F
→
03/28 21:07, , 4F
03/28 21:07, 4F
→
03/28 21:11, , 5F
03/28 21:11, 5F
→
03/28 21:12, , 6F
03/28 21:12, 6F
→
03/28 21:18, , 7F
03/28 21:18, 7F
→
03/28 21:20, , 8F
03/28 21:20, 8F
→
03/28 21:23, , 9F
03/28 21:23, 9F
→
03/28 21:25, , 10F
03/28 21:25, 10F
→
03/28 21:26, , 11F
03/28 21:26, 11F
→
03/28 21:27, , 12F
03/28 21:27, 12F
→
03/28 21:27, , 13F
03/28 21:27, 13F
→
03/28 21:29, , 14F
03/28 21:29, 14F
→
03/28 21:30, , 15F
03/28 21:30, 15F
推
03/29 20:53, , 16F
03/29 20:53, 16F
討論串 (同標題文章)