What does the if (0) command in r mean?

I have a question, I am looking at the code and in one script, the authors use:

if(0){ #do something } 

Any help on what if(0) means?

+5
source share
2 answers

The author (most likely) places the block of code in the if statement so that they can easily delete it if necessary, without having to comment on it (or delete it). Like if (true) or if (false), you just need to change one value and skip this code.

When viewing the code, developers should remove these types of statements as soon as they complete their entire source code so as not to confuse others.

+7
source

It looks like it will never be executed, since 0 = FALSE. Most likely, this is a manual switch for checking the code in brackets.

+1
source

All Articles