new_class | R Documentation |
This function declare a new class, and copies attributes and methods from parent classes.
new_class(
...,
env = new.env(parent = parent.frame()),
class_name = NULL,
empty_class = FALSE
)
... |
Environments. Parent class environments. |
env |
Environment. The new class environment. |
class_name |
Name of the new class. |
empty_class |
Boolean. Whether to create an empty class. This should only
be used when you don't want to inherited from BASE, or you want to define
your own base object class. Will be ignored if |
Parents can be provided in ...
, where methods and attributes will be
overrided by the left classes because bandicoot
does not support dynamic
dispatch at the moment. However, this behaviour usually aligns with the method
resolution order defined by the C3 algorithm used in Python.
If ...
is empty and empty_class == FALSE
,
BASE will be used as the parent class.
A class environment with S3 class "bandicoot_oop".
MYCLASS <- new_class(class_name = "MYCLASS")
MYCLASS
names(MYCLASS)
# Inhert from BASE class
TEST <- new_class(BASE, class_name = "TEST")
TEST
names(TEST)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.