mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 06:20:13 +00:00
Updating iterable.current comments and behavior to be consistent.
Change-Id: I57226491571272aa483aec8b5e14dc00c55511ed Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132812 Commit-Queue: Mark Zhou <markzipan@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
322b2493b7
commit
4d839404c9
2 changed files with 7 additions and 3 deletions
|
@ -13,8 +13,12 @@ part of dart.core;
|
|||
* and if the call returns `true`,
|
||||
* the iterator has now moved to the next element,
|
||||
* which is then available as [Iterator.current].
|
||||
* If the call returns `false`, there are no more elements,
|
||||
* and `iterator.current` returns `null`.
|
||||
* If the call returns `false`, there are no more elements.
|
||||
* The [Iterator.current] value must only be used when the most
|
||||
* recent call to [Iterator.moveNext] has returned `true`.
|
||||
* If it is used before calling [Iterator.moveNext] the first time
|
||||
* on an iterator, or after a call has returned false or has thrown an error,
|
||||
* reading [Iterator.current] may throw or may return an arbitrary value.
|
||||
*
|
||||
* You can create more than one iterator from the same `Iterable`.
|
||||
* Each time `iterator` is read, it returns a new iterator,
|
||||
|
|
|
@ -572,7 +572,7 @@ class TakeWhileIterator<E> extends Iterator<E> {
|
|||
}
|
||||
|
||||
E get current {
|
||||
if (_isFinished) throw IterableElementError.noElement();
|
||||
if (_isFinished) return null as E;
|
||||
return _iterator.current;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue