empty
Thanks for your feedback!
Was this page helpful?
Returns an empty read-only list. The returned list is serializable (JVM).
import kotlin.test.* fun main() { //sampleStart val list = listOf<String>() println("list.isEmpty() is ${list.isEmpty()}") // true // another way to create an empty list, // type parameter is inferred from the expected type val other: List<Int> = emptyList() // "Empty lists are equal" println("list == other is ${list == other}") // true println(list) // [] // list[0] // will fail //sampleEnd }
xxxxxxxxxx
val list = listOf<String>()
println("list.isEmpty() is ${list.isEmpty()}") // true
// another way to create an empty list,
// type parameter is inferred from the expected type
val other: List<Int> = emptyList()
// "Empty lists are equal"
println("list == other is ${list == other}") // true
println(list) // []
// list[0] // will fail
Thanks for your feedback!