iter {bandicoot}R Documentation

Build an iterator

Description

Build an iterator

Usage

iter(x, ...)

Arguments

x

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]