Reputation: 391
I have some R code that has if (TRUE)
before a function begins. What is the purpose of that conditional statement?
if (TRUE) {
f <- function(x, y) {
z <- x + y
z
}
f(2, 3)
}
Upvotes: 0
Views: 73
Reputation: 2105
Sometimes people will wrap blocks of code ...
in if (FALSE){ ... }
if they want to execute a whole script in one shot but are still working on the stuff in ...
. So seems plausible that whoever wrote it was satisfied enough with ...
that they want it to be executed whenever they source the script. (changing FALSE
to TRUE
is basically the same thing as just deleting the conditional)
Just a guess but that could explain it!
Upvotes: 2