-
Book Overview & Buying
-
Table Of Contents
Kotlin Design Patterns and Best Practices - Second Edition
By :
While the aim of this chapter wasn’t to cover all of Kotlin’s syntax features—we’ll explore more throughout this book—this chapter is still fairly lengthy. Therefore, it’s a good time to practice what you’ve learned with a short exercise, if you’re interested.
Write a function that takes a list of possibly nullable strings, each representing a sentence.
If a string is either null or empty, the function should print Skipped.
Otherwise, the function should capitalize each word in the string.
The function should return a single list containing all the capitalized words.
For the input listOf("hellO wOrlD", null, "fRom", null, "kOtlin"), the function should return listOf("Hello", "World", "From", "Kotlin").
Do you see an opportunity to use extension functions in this exercise...