Hi there, I’m just wondering if conditions in a if statement are checked in a lazy fashion. See the following snippet for an example. By saying lazy, I mean since in the if statement below, once a true is obtained, for example, if x > 10 is true, the entire condition section must be true, and the other two conditions do not need to be checked at all. So my question is if the other two conditions will be checked regardless of the outcome of the first. Thanks.
function checkConditions(uint256 x, uint256 y, uint256 z) public pure returns (bool) {
if (x > 10 || y < 230 || z > 56) revert InvalidValues(x, y, z);
// Do Sth.
}
As @cameel notes, this is not a property of if, it is a property of the && and || operators. So if you write bool x = f() && g(), g will only be called if f() returns true. Same for ||: In bool x = f() || g(), g() will only be called if f() returns false.