Skip to contents

This function performs the subtraction operator using the ..sub..() method. If it is not applicable, error will be raised.

Usage

# S3 method for bandicoot_oop
%-%(x, y)

Arguments

x

bandicoot_oop object.

y

Another object.

Value

Depends on the method.

Examples

COMPANY <- new_class(class_name = "COMPANY")
company <- COMPANY$instantiate
register_method(COMPANY,
                ..init.. = function(name, age) {
                  self$name <- name
                  self$age <- age
                })
register_method(COMPANY,
                ..sub.. = function(y) {
                  company(self$name[self$name != y],
                          self$age[self$name != y])
                })

good_company <- company(c("patrick", "james"),
                        c(33, 34))
new_company <- good_company %-% "patrick"
new_company$name
#> [1] "james"