Skip to content

Instantly share code, notes, and snippets.

@djnavarro
Created November 26, 2022 01:27
Show Gist options
  • Save djnavarro/b312b6c11ca62d0b14881a459d0c66a3 to your computer and use it in GitHub Desktop.
Save djnavarro/b312b6c11ca62d0b14881a459d0c66a3 to your computer and use it in GitHub Desktop.
# simple R6 class
Random <- R6::R6Class("Random",
active = list(draw = function() runif(1))
)
# instantiate the class
rnd <- Random$new()
# this calls the function
val <- rnd$draw
# this returns the function
fun <- activeBindingFunction("draw", rnd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment