A call in a loop runs again, so what its callee writes reaches the reads of the loop before the call as well: in ch <- function() g <<- 2; for(i in 1:2) { s <- g; ch() } the second s <- g reads g <<- 2.
ch <- function() g <<- 2; for(i in 1:2) { s <- g; ch() }
s <- g
g <<- 2
A call in a loop runs again, so what its callee writes reaches the reads of the loop before the call as well: in
ch <- function() g <<- 2; for(i in 1:2) { s <- g; ch() }the seconds <- greadsg <<- 2.