clone: clone

Description Usage Arguments Value Examples

View source: R/clone.R

Description

Clone an Iterator, making an exact copy that can then be modified separately. This is a simple wrapper around rlang::env_clone(). Optionally, override old initial parameters.

Usage

1
clone(iter, ...)

Arguments

iter

an Iterator object

...

optionally override the $initial parameters in iter

Value

a copy of the Iterator passed as a parameter

Examples

1
2
3
4
5
6
7
8
it <- Iterator({m <- m + n}, list(m = 0, n = 1), m)
other <- clone(it)
yield_next(it)
current(other) == current(it) # false

it2 <- clone(other, n = 5)
yield_next(it2)
it2$initial$n  # 5

jacgoldsm/pytools documentation built on March 17, 2021, 6:36 a.m.