Home > Back-end >  Expected expression in conditional / guard / Swift
Expected expression in conditional / guard / Swift

Time:10-15

Please helpXcode screenshot I bump into error with "Expected expression in conditional" and can't figure out a solution by myself Thanks!

public func signUp(
    email: String,
    password: String,
    completion: @escaping (Bool) -> Void
) {
    guard !email.trimmingCharacters(in: .whitespaces).isEmpty,
    guard !password.trimmingCharacters(in: .whitespaces).isEmpty,
          password.count >= 6 else {
        return
    }
    
    auth.createUser(withEmail: email, password: password) { result, error in
        guard result != nil, error == nil else {
            completion(false)
            return
        }
        
        //Account Created
        completion(true)
    }
}

CodePudding user response:

Change:

guard !email.trimmingCharacters(in: .whitespaces).isEmpty,
guard !password.trimmingCharacters(in: .whitespaces).isEmpty,
    password.count >= 6 else {
    return
}

To:

guard !email.trimmingCharacters(in: .whitespaces).isEmpty,
    !password.trimmingCharacters(in: .whitespaces).isEmpty,
    password.count >= 6 else {
    return
}
  • Related