Here is an example of my code. I need the last if
to do nothing, else do something.
if (daPilot.Gas > 0)
;
else
daPilot.failMessage3();
Answer: use _ = 0 . I came up with the following code example which is valid in .
If you want your last else to do nothing, you can use the continue keyword inside it. For any conditional you can define the conditional to do nothing by defining an empty code block {} for it or by simply ommit the case.
A condition need not necessarily contain comparators such as == or < etc. A condition can be any expression. Now, if the if expression evaluates to a zero value it is considered false and the if statement is not evaluated. Otherwise, it is considered true and the if statement is evaluated.
You've already done it. Congratulations.
Of course the far less confusing design is to just NOT the condition and then have an if
with no else
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With