Why does the IDE indicate that a code in the "if" will not be executed?

Asked

Viewed 101 times

-1

Observe the code:

Código no IDE

Because the development IDE is not considering line 34, 35 and 36 code?

You weren’t supposed to be on probation?

  • 5

    5 is never greater than 6. The condition will never be true. Therefore it should never enter into the conditional.

  • Your code has other strange things. For example, on line 39 you are doing an assignment that will always return true, within the if.

1 answer

8


Ides just show it to you, probably him it’s not what you think. The compiler understands the code and generates something that will be executed or not. Then there is nothing wrong with the code. What Ides do is guide when he sees something that is weird and shouldn’t be there. It is the case of these three lines that don’t need to exist. Since 5 is never greater than 6 the condition will always be false and the content of if will never be executed, so all three lines are innocuous and should be removed from the code. Even if it was always true there the if could be eliminated, leaving only direct increment without conditional.

As a consequence in this case you will never get probation when you run it, it is a clear false condition and the IDE has already informed you so that you do not waste time with this code

  • thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.