Write a function that accepts a list of objects and returns only those list items that are strings.
Type cast and smart cast
In the game only String
Report a typo
Sample Input 1:
"apple", 1, "banana", 2, "orange"Sample Output 1:
[apple, banana, orange]Write a program in Kotlin
fun <T> getStringsOnly(list: List<T>): List<String> {
val result = mutableListOf<String>()
// make your code here
return result
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.