# NOT RUN {
# }
# NOT RUN {
a <- 1
# will evaluate the expression first
x %<-% { message('evaluating expression "x"'); a + 1 }
x # 2
# will reuse cached value
{
message('evaluating expression "y"')
a + 1
# even if written a bit differently
} %->% y
y # 2
a <- -1
# will evaluate the expression again
x # 0
# will load the new cached value
y # 0
setCached(z, x + y)
a <- 0
z # recalculates all three
# }
Run the code above in your browser using DataLab