[英]How to suppress compiler warning
this code: 这段代码:
guard let isNotNil = anOptional
else {
#if DEBUG
fatalError()
#endif
return false
}
gives a compiler warning when in debug mode on return false
: 在调试模式下
return false
时给出编译器警告:
Will never been executed
永远不会被执行
Which is right but by intention. 哪个是正确的但是有意。
How can I suppress this warning? 我怎么能压制这个警告?
With an else statement: 用else语句:
guard let isNotNil = anOptional
else {
#if DEBUG
fatalError()
#else
return false
#endif
}
You can also go to the project or the target build settings and disable the warning for unreachable code. 您还可以转到项目或目标构建设置,并禁用无法访问代码的警告。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.