consume {iterors}R Documentation

Consumes the first n elements of an iterator

Description

Advances the iterator n-steps ahead without returning anything.

Usage

consume(obj, n = Inf, ...)

## S3 method for class 'iteror'
consume(obj, n = Inf, ...)

Arguments

obj

an iterable object

n

The number of elements to consume.

...

passed along to iteror constructor.

Value

obj, invisibly.

See Also

take collect

Examples

it <- iteror(1:10)
# Skips the first 5 elements
consume(it, n=5)
# Returns 6
nextOr(it, NA)

it2 <- iteror(letters)
# Skips the first 4 elements
consume(it2, 4)
# Returns 'e'
nextOr(it2, NA)

[Package iterors version 1.0 Index]