[R] if/else at 1.3.1

HEUMANN,JOHN (A-Loveland,ex1) john_heumann at agilent.com
Thu Oct 18 03:22:26 CEST 2001


Under NT with 1.3.1

if (x == 1) {
  cat("Saw x=1\n");
} else {
  cat("Saw x!=1\n");
}

works as expected, but 

if (x == 1) {
  cat("Saw x=1\n");
} 
else {
  cat("Saw x!=1\n");
}

is currently giving me a syntax error on the "else" line. 
Apparently the parser considers the if statement to have 
ended as soon as it sees first closing brace, unless 
there's an else on the same line.

IIRC, both forms were accepted at 1.3.0. Is this a bug, 
or intentional? I don't see any mention of this
change in the "What's New" notes. BTW, I didn't notice
this behavior until after a crash (caused by a known
package bug) which blew me all the way out of RGui, 
so its possible I've corrupted my installation...

Thanks,
-jh-

=========================================
John M. Heumann, Agilent Technologies
815 14th St. S.W., Loveland, CO 80537 USA
Email: john_heumann at agilent.com
Phone: 970 679-3761 FAX: 970 679-5399
=========================================
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list