14.5 R6 objects and method chaining

  • All side-effect R6 methods should return self invisibly.
  • This allows for method chaining.
x$add(10)$add(10)$sum
# [1] 24
  • To improve readability:
# Method chaining
x$
  add(10)$
  add(10)$
  sum
# [1] 44