I’d like to return a list if it only contains obje...
# codereview
j
I’d like to return a list if it only contains objects of a class, otherwise an empty list. Is there a nicer way than the following?
Copy code
return if (list.size == list.filterIsInstance<MyClazz>().size) {
        list
    } else {
        emptyList()
    }