Skip to content
Prev 24995 / 398502 Next

R bug? (if-else problem in main program)

"Lorenz Gygax" <gygax at ifi.unizh.ch> writes:
Yep. And it isn't a bug, but a design issue. In interactive mode we
print the result of an expression as soon as it is syntactically
complete, so upon seeing
[1] "yes"

we assume that we are done with that statement. After all, the next
line might be completely unrelated, e.g. "b <- 2", so we cannot wait
and see whether it starts with "else". So you need to ensure somehow
that the line is not syntactically complete, using braces as above, or,
e.g.,
+ print("no")
[1] "yes"