size

expect open override val size: Int(source)

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.0

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   println(listOf(1, 2, 3).size) // 3
println(emptySet<Int>().size) // 0
println(mapOf(1 to "one", 2 to "two").size) // 2 
   //sampleEnd
}