【问题标题】:How to return boolean value from a function in Swift如何从 Swift 中的函数返回布尔值
【发布时间】:2015-02-17 22:33:16
【问题描述】:

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

func checkEmail ()

{
   var test = true

   return test
}

...elsewhere in the code....

var emailStatus = checkEmail ()

如何让这个函数返回 true 的布尔值?

【问题讨论】:

    标签: xcode function swift boolean


    【解决方案1】:
    func checkEmail() -> Bool {
       var test = true
       return test
    }
    

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

    var emailStatus = checkEmail()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-11
      • 1970-01-01
      • 2021-02-16
      • 1970-01-01
      • 2017-10-29
      • 2017-06-07
      • 2011-07-22
      • 1970-01-01
      相关资源
      最近更新 更多