Kotlin List toUIntArray()
Syntax & Examples
Syntax of List.toUIntArray()
The syntax of List.toUIntArray() extension function is:
fun Collection<UInt>.toUIntArray(): UIntArrayThis toUIntArray() extension function of List returns an array of UInt containing all of the elements of this collection.
✐ Examples
1 Example
In this example,
- We create a list named 
list1containing the characters'a', 'p', 'p', 'l', 'e'. - We convert 
list1to a SortedSet using thetoSortedSet()function. - The resulting SortedSet contains all unique elements from the list, sorted in natural order.
 - Finally, we print 
sortedSet1to standard output. 
Kotlin Program
fun main(args: Array<String>) {
    val list1 = listOf("a", "p", "p", "l", "e");
    val sortedSet1 = list1.toSortedSet();
    println(sortedSet1);
}Output
[a, e, l, p]
2 Example
In this example,
- We create a list named 
list2containing integers30, 10, 20, 40, 20. - We convert 
list2to a SortedSet using thetoSortedSet()function. - The resulting SortedSet contains unique elements from the list, sorted in natural order.
 - Finally, we print 
sortedSet2to standard output. 
Kotlin Program
fun main(args: Array<String>) {
    val list2 = listOf(30, 10, 20, 40, 20);
    val sortedSet2 = list2.toSortedSet();
    println(sortedSet2);
}Output
[10, 20, 30, 40]
3 Example
In this example,
- We create a list named 
list3containing strings'apple', 'banana', 'orange', 'banana', 'apple'. - We convert 
list3to a SortedSet using thetoSortedSet()function. - The resulting SortedSet contains unique elements from the list, sorted in natural order.
 - Finally, we print 
sortedSet3to standard output. 
Kotlin Program
fun main(args: Array<String>) {
    val list3 = listOf("apple", "banana", "orange", "banana", "apple");
    val sortedSet3 = list3.toSortedSet();
    println(sortedSet3);
}Output
[apple, banana, orange]
Summary
In this Kotlin tutorial, we learned about toUIntArray() extension function of List: the syntax and few working examples with output and detailed explanation for each example.