size
Returns the size of the collection.
If a collection contains more than Int.MAX_VALUE elements, the value of this property is unspecified. For implementations allowing to have more than Int.MAX_VALUE elements, it is recommended to explicitly document behavior of this property.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
assertEquals(3, listOf(1, 2, 3).size)
assertEquals(0, emptySet<Int>().size)
assertEquals(2, mapOf(1 to "one", 2 to "two").size)
//sampleEnd
}