Skip to content

Instantly share code, notes, and snippets.

@darioappsilon
Created May 12, 2022 08:41
Show Gist options
  • Save darioappsilon/5fc43f53219bb6e41fd24d087309976c to your computer and use it in GitHub Desktop.
Save darioappsilon/5fc43f53219bb6e41fd24d087309976c to your computer and use it in GitHub Desktop.
Animal <- R6Class(
classname = "Animal",
public = list(
initialize = function(name = NA, age = NA, number_of_legs = NA) {
private$name = name
private$age = age
private$number_of_legs = number_of_legs
},
make_sound = function(sound) {
cat(private$name, " says ", sound, "\n", sep = "")
}
),
private = list(
name = NULL,
age = NULL,
number_of_legs = NULL
)
)
Dog <- R6Class(
classname = "Dog",
inherit = Animal,
public = list(
initialize = function(name = NA, age = NA, number_of_legs = NA, hair_color = NA) {
super$initialize(name, age, number_of_legs)
private$hair_color = hair_color
}
),
private = list(
hair_color = NULL
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment