Iterable
interface Iterable<T : Any!>
| java.lang.Iterable |
Implementing this interface allows an object to be the target of the "for-each loop" statement. See For-each Loop
Summary
| Public methods | |
|---|---|
| open Unit |
Performs the given action for each element of the |
| abstract MutableIterator<T> |
iterator()Returns an iterator over elements of type |
| open Spliterator<T> |
Creates a |
Public methods
forEach
open fun forEach(action: Consumer<in T>): Unit
Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.
| Parameters | |
|---|---|
action |
Consumer<in T>: The action to be performed for each element |
| Exceptions | |
|---|---|
java.lang.NullPointerException |
if the specified action is null |
iterator
abstract fun iterator(): MutableIterator<T>
Returns an iterator over elements of type T.
| Return | |
|---|---|
MutableIterator<T> |
an Iterator. |
spliterator
open fun spliterator(): Spliterator<T>
Creates a Spliterator over the elements described by this Iterable.
| Return | |
|---|---|
Spliterator<T> |
a Spliterator over the elements described by this Iterable. |