Tag: mutable

否则,Kotlin检查两次null

我有一个variablesdatePurchased的项目,可以为null。 根据购买日期,我生成一个标签。 当我检查datePurchased是否为空,否则我仍然必须检查为空。 它说聪明的演员是不可能的,因为这是一个可变的财产。 以下是我迄今为止所尝试的: if (datePurchased == null) { “” } else { if (datePurchased.isToday()) {//error here } } when { datePurchased == null -> { } datePurchased.isToday() -> {//smart cast bla bla mutable bla bla datePurchased?.isToday() -> {//expected Boolean, got Boolean? datePurchased?.isToday()?:false -> {//all good, but does not look nice, since datePurchased can’t […]