proto-package {proto} | R Documentation |
Object-oriented programming with the prototype model. "proto"
facilitates object-oriented programming using an approach that emphasizes
objects rather than classes (although it is powerful enough to readily
represent classes too).
cat("parent\n") oop <- proto(x = 10, view = function(.) paste("this is a:", .$x)) oop$ls() oop$view() cat("override view in parent\n") ooc1 <- oop$proto(view = function(.) paste("this is a: ***", .$x, "***")) ooc1$view() cat("override x in parent\n") ooc2 <- oop$proto(x = 20) ooc2$view()