Kotlin - Collections Fundamentals
You have a list of user names and want to print how many users are online only if the list is not empty. Which Kotlin code snippet correctly does this?
users.size > 0 correctly checks if the list has one or more elements.isEmpty() checks for empty, so if (users.isEmpty()) println("Online users: ${users.size}") prints when empty, which is wrong.count is a function, so count == 0 is invalid.isNotEmpty without parentheses is incorrect syntax.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions