我们如何在swift for循环中实现<=和> =操作.我试过没有运气.
以下是我试过的选项
for i in 1..<=3{
print(i)
}
Run Code Online (Sandbox Code Playgroud)
错误:使用未解析的运算符'.. <='for i in 1 .. <= 3 {
rob*_*off 10
您正在寻找"闭区域运营商".它是拼写...:
for i in 1 ... 3 {
print(i)
}
Run Code Online (Sandbox Code Playgroud)
您可以在Swift Programming Lanugage的 "Basic Operators"下阅读更多相关内容.
在 C/Java 中:
for(int i=1 ; i<=3 ; i++)
print(i)
Run Code Online (Sandbox Code Playgroud)
迅速:
for i in 1 ... 3 {
print(i)
}
Run Code Online (Sandbox Code Playgroud)
在 C/Java 中:
for(int i=1 ; i<3 ; i++)
print(i)
Run Code Online (Sandbox Code Playgroud)
迅速:
for i in 1 ..< 3 {
print(i)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5590 次 |
| 最近记录: |