Added Int.indices extension property.
This commit is contained in:
@@ -13,6 +13,9 @@ val Collection<*>.empty : Boolean
|
|||||||
val Collection<*>.indices : IntRange
|
val Collection<*>.indices : IntRange
|
||||||
get() = 0..size-1
|
get() = 0..size-1
|
||||||
|
|
||||||
|
val Int.indices: IntRange
|
||||||
|
get() = 0..this-1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the collection to an array
|
* Converts the collection to an array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -366,6 +366,11 @@ class CollectionTest {
|
|||||||
assertEquals(1, indices.end)
|
assertEquals(1, indices.end)
|
||||||
assertEquals(2, indices.size)
|
assertEquals(2, indices.size)
|
||||||
assertFalse(indices.isReversed)
|
assertFalse(indices.isReversed)
|
||||||
|
|
||||||
|
val sizeIndices = data.size.indices
|
||||||
|
assertEquals(0, sizeIndices.start)
|
||||||
|
assertEquals(1, sizeIndices.end)
|
||||||
|
assertEquals(2, sizeIndices.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
test fun contains() {
|
test fun contains() {
|
||||||
|
|||||||
Reference in New Issue
Block a user