Created
June 5, 2019 03:12
-
-
Save bfatemi/1378dae8a26fa5073f2a1bb6064bd934 to your computer and use it in GitHub Desktop.
activeBinding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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