Chapter 2
Tips to Make Code More Robust and Error-Free
Section 3
Kotlin Methods for Eliminating Nulls from a Collection
Removing null elements from a collection is a common situation. But this can involve several operations, making code long, verbose, and open to errors. Provide solutions for removing null elements which are concise and clear. - Apply filterNotNull for removing nulls from a collection - Use the listOfNotNull function to create a null-free collection - Run the code for both solutions to confirm that lists have no nulls