Skip to content
Prev 343409 / 398506 Next

Display warning only once in session

Is local preferred to prevent *any* access to the internal environment
of the returned function?

How is it different than this?

myFunc <- function() {
    notWarnedYet <- TRUE
    function(x) {
        if (notWarnedYet) {
            warning("myFunc is funky")
            notWarnedYet <<- FALSE # note use of <<-
        }
        sqrt(log2(x))
    }
}
Grant Rettke | ACM, ASA, FSF, IEEE, SIAM
gcr at wisdomandwonder.com | http://www.wisdomandwonder.com/
?Wisdom begins in wonder.? --Socrates
((? (x) (x x)) (? (x) (x x)))
?Life has become immeasurably better since I have been forced to stop
taking it seriously.? --Thompson
On Mon, Aug 25, 2014 at 4:50 PM, William Dunlap <wdunlap at tibco.com> wrote: