加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift2 – Swift 2:防守身体可能不会错过错误

发布时间:2020-12-14 05:57:54 所属栏目:百科 来源:网络整理
导读:我有以下的守卫片段,这是产生错误的’守卫身体可能不会通过’。怎么了? guard NSFileManager.defaultManager().fileExistsAtPath(appBundlePath) else { print("App bundle doesnt exist") } 警卫声明需要有一些东西来使程序的流程远离封闭的范围(例如,最
我有以下的守卫片段,这是产生错误的’守卫身体可能不会通过’。怎么了?
guard NSFileManager.defaultManager().fileExistsAtPath(appBundlePath) else {
        print("App bundle doesnt exist")
 }
警卫声明需要有一些东西来使程序的流程远离封闭的范围(例如,最可能的情况是返回从函数返回)。这是必需的,因为守卫守卫不会有效,所以程序流程需要去别的地方!

Documentation:

The else clause of a guard statement is required,and must either call
a function marked with the noreturn attribute or transfer program
control outside the guard statement’s enclosing scope using one of the
following statements:

  • return
  • break
  • continue
  • throw

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读