The R Project SVN R

Rev

Rev 88267 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 88267 Rev 88536
Line 462... Line 462...
462
## test of callSuper() to a hidden default method for initialize() (== initFields)
462
## test of callSuper() to a hidden default method for initialize() (== initFields)
463
TestClass <- setRefClass ("TestClass",
463
TestClass <- setRefClass ("TestClass",
464
     fields = list (text = "character"),
464
     fields = list (text = "character"),
465
     methods = list(
465
     methods = list(
466
       print = function ()  {cat(text)},
466
       print = function ()  {cat(text)},
467
       initialize = function(text = "", ...) callSuper(text = paste(text, ":", sep=""),...)
467
       initialize = function(text = "", ...) callSuper(text = paste0(text, ":"),...)
468
  ))
468
  ))
469
tt <- TestClass("hello world")
469
tt <- TestClass("hello world")
470
stopifnot(identical(tt$text, "hello world:"))
470
stopifnot(identical(tt$text, "hello world:"))
471
## now a subclass with another field & another layer of callSuper()
471
## now a subclass with another field & another layer of callSuper()
472
TestClass2 <- setRefClass("TestClass2",
472
TestClass2 <- setRefClass("TestClass2",