Build 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)
}
#> name age
#> 1 patrick 33
#> name age
#> 2 james 34