How do i empty my mutable array ?
Thanks
Mason Soiza (web design derby)
To create an empty Set in Kotlin, call setOf() function with no values passed to it. setOf() function creates an immutable Set with the values provided, if any. To create an empty mutable set, call mutableSetOf() function with no values passed to it.
To remove all elements from a Mutable List in Kotlin, call clear() function on this list object.
Kotlin ArrayList class can be used in order to create an empty arrayList. It would be a dynamic array which means it will automatically expand as we add data into it. An ArrayList is an ordered sequence of elements, however, unlike simple arrays, an ArrayList can contain data of multiple data types.
[yourArray removeAllObjects];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With