How to return boolean value from a function in Swift

37,098
func checkEmail() -> Bool {
   var test = true
   return test
}

Elsewhere in the code....

var emailStatus = checkEmail()
Share:
37,098

Related videos on Youtube

Schuey999
Author by

Schuey999

Updated on October 20, 2020

Comments

  • Schuey999
    Schuey999 over 3 years

    I've looked around but was suprised that I couldn't really find anything that explained this. If I have:

    func checkEmail ()
    
    {
       var test = true
    
       return test
    }
    
    ...elsewhere in the code....
    
    var emailStatus = checkEmail ()
    

    How can I make this function return the boolean value of true?