14.4 Constructing an R6 object

  • Just use $new()
x <- Accumulator$new()
x$add(4)
x$sum
#> [1] 4