Schuey999
Schuey999

Reputation: 4986

How to return boolean value from a function in Swift

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?

Upvotes: 29

Views: 43522

Answers (1)

Jie Li
Jie Li

Reputation: 1066

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

Elsewhere in the code....

var emailStatus = checkEmail()

Upvotes: 64

Related Questions