applied pull request with thanks https://github.com/JetBrains/kotlin/pull/46
This commit is contained in:
@@ -172,6 +172,14 @@ val <T> List<T>.last : T?
|
||||
return if (s > 0) this.get(s - 1) else null
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the last item in the list or -1 if the list is empty
|
||||
*
|
||||
* @includeFunctionBody ../../test/ListTest.kt lastIndex
|
||||
*/
|
||||
val <T> List<T>.lastIndex : Int
|
||||
get() = this.size - 1
|
||||
|
||||
/**
|
||||
* Returns the first item in the list
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user