DEV Community

Pavnesh Kumar
Pavnesh Kumar

Posted on

Answer: How to use completionHandler Closure with return in Swift?

completionHandler Closure with return in Swift

func checkPassword(pass:String,com:@escaping(Bool)-> String){
    if pass.count < 5{
        let pass = com(false)
        print("Pleas check your password :\(pass)")
    }else{
        let pass = com(true)
        print("You can use this password : \(pass)")
    }
}
let password = "test@1"

checkPassword(pass:password ) { (status) in
    if status{
        print("Strong Password")
    }else{

Top comments (0)