hasNext: Does This Iterator Have A Next Element

Description Usage Arguments Value Examples

Description

hasNext is a generic function that indicates if the iterator has another element.

Usage

1
2
3
4
hasNext(obj, ...)

## S3 method for class 'ihasNext'
hasNext(obj, ...)

Arguments

obj

an iterator object.

...

additional arguments that are ignored.

Value

Logical value indicating whether the iterator has a next element.

Examples

1
2
3
  it <- ihasNext(iter(c('a', 'b', 'c')))
  while (hasNext(it))
    print(nextElem(it))

Example output

Loading required package: iterators
[1] "a"
[1] "b"
[1] "c"

itertools documentation built on May 2, 2019, 2:26 p.m.