NotEmptyList
Represents a list that has at least one element of type E.
You can use the notEmptyListOf or the toNotEmptyList functions for creating an instance of this type.
Serialization and deserialization
The serialization and deserialization processes of this type behave like for the List type.
Here's an example of Kotlin code that encodes and decodes this type using the JavaScript Object Notation (JSON) format from kotlinx.serialization:
val string: NotEmptyList<Int> = notEmptyListOf(1, 2, 3)
val encoded: String = Json.encodeToString(string)
assertEquals(expected = "[1,2,3]", actual = encoded)
val decoded: NotEmptyList<Int> = Json.decodeFromString(encoded)
assertEquals(expected = string, actual = decoded)
Content copied to clipboard
Types
Link copied to clipboard
object Companion
Contains static declarations for the NotEmptyList type.