Multiple conditions in guard statement in Swift

Check this code

func demo(){

    var str = [String: String]()

    str["status"] = "blue"
    str["asd"] = nil

    guard let var2 = str["asd"], let var1 = str["status"]
    else
    {
        print("asdsfddffgdfgdfga")
        return
    }
    print("asdasdasd")
}

Guard will check one by one condition. If the first is true then it will check the next. Otherwise, it will execute the else part.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)