get

inline operator fun <T> Iterable<T>.get(position: Int): T(source)

Returns the element at the specified position in an iterable.

Stream equivalent: stream.skip(position).findFirst().get() (throws NoSuchElementException if out of bounds)

Return

the element at the specified position in this

See also

Parameters

position

position of the element to return

Throws

if position is negative or greater than or equal to the size of this


inline fun <T> Iterable<T>.get(position: Int, defaultValue: T? = null): T(source)

Returns the element at the specified position in an iterable or a default value otherwise.

Return

the element at the specified position in this, or defaultValue if this produces fewer that position + 1 elements and defaultValue is not null.

See also

Parameters

position

position of the element to return

defaultValue

the default value to return if position is greater than the size of this

Throws

if position is negative, or if position is greater than or equal to the number of elements remaining in this and defaultValue is null.


inline operator fun <T> Iterator<T>.get(position: Int): T(source)

Advances thisposition + 1` times, returning the element at the positionth position.

Return

the element at the specified position in this

See also

Parameters

position

position of the element to return

Throws

if position is negative or greater than or equal to the number of elements remaining in this.


inline fun <T> Iterator<T>.get(position: Int, defaultValue: T? = null): T(source)

Advances thisposition + 1` times, returning the element at the positionth position or a default value otherwise.

Return

the element at the specified position in this, or defaultValue if this produces fewer that position + 1 elements and defaultValue is not null.

See also

Parameters

position

position of the element to return

defaultValue

the default value to return if the iterator is empty or if position is greater than the number of elements remaining in this

Throws

if position is negative, or if position is greater than or equal to the number of elements remaining in this and defaultValue is null.