Skip to content

Instantly share code, notes, and snippets.

@bfatemi
Created June 5, 2019 03:12
Show Gist options
  • Save bfatemi/1378dae8a26fa5073f2a1bb6064bd934 to your computer and use it in GitHub Desktop.
Save bfatemi/1378dae8a26fa5073f2a1bb6064bd934 to your computer and use it in GitHub Desktop.
activeBinding
ABC <- local({
x <- 1
function(v) {
if (missing(v)){
cat("get\n")
} else {
cat("set\n")
x <<- v
}
x
}
})
makeActiveBinding("A", ABC, current_env())
makeActiveBinding("B", ABC, current_env())
makeActiveBinding("C", ABC, current_env())
A
B
C
ABC()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment