【问题标题】:Determine if a list is empty?确定列表是否为空?
【发布时间】:2022-06-22 07:06:09
【问题描述】:
var team = []

如何判断team是否为空?

我试过了:

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

但它不起作用,因为它打印了List is empty!

【问题讨论】:

    标签: wren


    【解决方案1】:
    var team = []
    
    System.print(team.count == 0) // Output: false
    System.print(team.isEmpty) // Output: false
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多