In the code below

*ff <- function(n){ for(i in 1:n) (i+1)}*

*n<-3;ff(n)->op;print(op)*

Why doesnt *print(op) * print 4 and instead prints NULL.
Isnt the last line of code executed is *i+1 * and therefore that should be
returned instead of NULL

instead if I say
*ff <- function(n){ (n+1) }*

Then
*n<-3;ff(n)->op;rm(n);print(op)*
gives 4 as output.

My question is *Which *is considered as the last line in a functoin for the
purpsoe of default return ? And under what conditions ?

-Thanks,
Ramnik

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to