How to package functions into a simple class of static methods

Viewed 20

I need to pack a number of functions into a group. I want to use some of the simplest and cheapest class for this, and publish the functions in it as a set of static methods.

Example via list:

myClass <- list(
    func1 = function(x) {print(x)},
    func2 = function(x) {print(paste0(x, ' SECOND'))}
)

> myClass$func1('test')
# [1] "test"
> myClass$func2('test')
# [1] "test SECOND"

The only problem is that I want to use a class, not a list.

Tell me the easiest and cheapest way, please

0 Answers
Related