swift if or/and 语句像 python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26456587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 00:30:21 来源:igfitidea点击:
swift if or/and statement like python
提问by Tomblasta
Is there a way to to do and/or in an if statement in swift. eg/
有没有办法在 swift 中做和/或在 if 语句中。例如/
if a > 0 and i == j or f < 3:
//do something
can we do that in swift?
我们可以迅速做到这一点吗?
Thanks in advance
提前致谢
采纳答案by user3400223
You can use
您可以使用
&&
for logical and
对于逻辑和
||
for logical or
对于逻辑或
so you can do
所以你可以做
if a > 0 && i == j || f < 3 {
...
}

