如何从Swift中的函数返回布尔值

时间:2021-04-09 16:04:24

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?

如何使此函数返回布尔值true?

1 个解决方案

#1


34  

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

Elsewhere in the code....

在代码的其他地方....

var emailStatus = checkEmail()

#1


34  

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

Elsewhere in the code....

在代码的其他地方....

var emailStatus = checkEmail()