On 11-09-19 5:11 PM, Gene Leynes wrote:
I thought that invisible works like return()
However, it appears that it doesn't exit a function.  Is it supposed to work
this way?




Yes, invisible() just marks its argument as non-printing. You still need to return it. (The man page is a little ambiguous, but what it is saying is that a call to invisible() returns a non-printing object. It isn't saying that it triggers a return from the caller.)

Duncan Murdoch

>

funInvisible = function(){
     invisible(10)
     cat('I was not expecting this to print\n')
     cat('because it occurs after the invisible return\n')
}
funInvisible()


funVisible = function(){
     cat('start of function\n')
     return(10)
     cat('This error is safely avoided: \n')
     cat(1 / 0)
}
funVisible()

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

______________________________________________
R-help@r-project.org mailing list
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