Swift 'if let' statement equivalent in Kotlin

前端 未结 14 1916
心在旅途
心在旅途 2020-12-02 07:32

In Kotlin is there an equivalent to the Swift code below?

if let a = b.val {

} else {

}
14条回答
  •  离开以前
    2020-12-02 08:09

    Swift if let statement in Kotlin

    The short answer is use simple IF-ELSE as by the time of this comment there is no equivalent in Kotlin LET,

        if(A.isNull()){
    // A is null
        }else{
    // A is not null
        }
    

提交回复
热议问题