Skip to content

Instantly share code, notes, and snippets.

@kohske
Created September 8, 2014 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohske/ce83301f4e666156a722 to your computer and use it in GitHub Desktop.
Save kohske/ce83301f4e666156a722 to your computer and use it in GitHub Desktop.
R6 extension
Person <- R99Class("Person",
public : {
name = NA
hair = NA
# initialize
initialize = function(name, hair) {
if (!missing(name)) self$name <- name
if (!missing(hair)) self$hair <- hair
self$greet()
}
# methods...
set_hair = function(val) {
self$hair <- val
}
greet = function() {
cat(paste0("Hello, my name is ", self$name, ".\n"))
}
},
private : {
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment