swift if或/和python这样的语句 [英] swift if or/and statement like python

查看:93
本文介绍了swift if或/和python这样的语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在swift中执行和/或在if语句中。例如/

Is there a way to to do and/or in an if statement in swift. eg/

if a > 0 and i == j or f < 3:
    //do something 

我们能在swift中做到吗?

can we do that in swift?

提前致谢

推荐答案

您可以使用

&&

用于逻辑和

|| 

为逻辑或

所以你可以如果a>那么

so you can do

if a> 0 && i ==j || f<3:
    ...

见这里
https://developer.apple.com/library/ios/documentation/swift/conceptual/Swift_Programming_Language/ BasicOperators.html

这篇关于swift if或/和python这样的语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆