3.6 短路求值:先做安全檢查
&&、|| 有一個特性,叫做短路求值:
&&左邊如果已經是false,結果一定是false,右邊就完全不會被計算。||左邊如果已經是true,結果一定是true,右邊也不會被計算。
這個特性可以幫我們在條件裡先做安全檢查,避免程式當掉。
Log in to read the full content
The syntax book is free for every AACPOJ account. Signing up takes a minute.