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

时间:2014-12-19 01:13:36

标签: xcode function swift boolean

我环顾四周,但很惊讶我找不到任何解释这个的东西。如果我有:

func checkEmail ()

{
   var test = true

   return test
}

...elsewhere in the code....

var emailStatus = checkEmail ()

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

1 个答案:

答案 0 :(得分:40)

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

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

var emailStatus = checkEmail()