notEmptyListOf

@Since(version = KotoolsTypesVersion.V4_0_0)
fun <E> notEmptyListOf(head: E, vararg tail: E): NotEmptyList<E>

Creates a NotEmptyList starting with a head and containing all the elements of the optional tail.


Calling from Kotlin

Here's an example of calling this function from Kotlin code:

val integers: NotEmptyList<Int> = notEmptyListOf(1, 2, 3)
val actual: List<Int> = integers.toList()
val expected: List<Int> = listOf(1, 2, 3)
assertContentEquals(expected, actual)

The NotEmptyList type being an inline value class, it is not recommended to call this function from Java code.