2014-12-19 104 views
13

我环顾四周,但很惊讶,我找不到任何解释这一点的东西。如果我有:如何从Swift中的函数返回布尔值

func checkEmail() 

{ 
    var test = true 

    return test 
} 

...elsewhere in the code.... 

var emailStatus = checkEmail() 

我该如何让该函数返回布尔值true?

回答

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

在别处在代码....

var emailStatus = checkEmail()