Skip to contents

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

Usage

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

Arguments

x

bandicoot_oop object.

y

Another object.

Value

A Boolean value.

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,
                ..contains.. = function(y) y %in% self$name)

good_company <- company(c("patrick", "james"),
                        c(33, 34))
good_company %contains% "patrick"
#> [1] TRUE