Determine if a list is empty?

var team = []

How do I determine if team is empty?

I tried:

if (team){
  System.print("List is empty!")
}

but it doesn’t work because List is empty! gets printed with or without elements.

>Solution :

var team = []

System.print(team.count == 0) // Output: false
System.print(team.isEmpty) // Output: false

Leave a Reply