iter.bandicoot_oop {bandicoot}R Documentation

S3 method of building an iterator of a bandicoot_oop object

Description

This function builds an iterator using the ..iter..() method. If it is not applicable, error will be raised.

Usage

## S3 method for class 'bandicoot_oop'
iter(x, ...)

Arguments

x

bandicoot_oop object.

...

Additional arguments needed for building an iterator.

Value

An iterator.

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,
                ..iter.. = function(...) {
                  split(data.frame(name = self$name, age = self$age),
                        1:length(self$name))
                })

good_company <- company(c("patrick", "james"),
                        c(33, 34))
for (person in iter(good_company)) {
  print(person)
}


[Package bandicoot version 1.0.0 Index]