KT-20357 Add samples for elementAtOrNull
This commit is contained in:
committed by
Ilya Gorbunov
parent
ad9b700ec4
commit
7d5efe7f51
@@ -116,6 +116,8 @@ public inline fun <T> List<T>.elementAtOrElse(index: Int, defaultValue: (Int) ->
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection.
|
||||
*
|
||||
* @sample samples.collections.Collections.Usage.elementAtOrNull
|
||||
*/
|
||||
public fun <T> Iterable<T>.elementAtOrNull(index: Int): T? {
|
||||
if (this is List)
|
||||
@@ -134,6 +136,8 @@ public fun <T> Iterable<T>.elementAtOrNull(index: Int): T? {
|
||||
|
||||
/**
|
||||
* Returns an element at the given [index] or `null` if the [index] is out of bounds of this list.
|
||||
*
|
||||
* @sample samples.collections.Collections.Usage.elementAtOrNull
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> List<T>.elementAtOrNull(index: Int): T? {
|
||||
|
||||
Reference in New Issue
Block a user