How can we implement <= and >= operations in swift for loop. i tried stide operations no luck.
Below is the option I tried
for i in 1..<=3{
print(i)
}
error: use of unresolved operator '..<=' for i in 1..<=3{
You are looking for the “closed range operator”. It is spelled ...
:
for i in 1 ... 3 {
print(i)
}
You can read more about it under “Basic Operators” in The Swift Programming Lanugage.
in c / java:
for(int i=1 ; i<=3 ; i++)
print(i)
in swift:
for i in 1 ... 3 {
print(i)
}
in c / java:
for(int i=1 ; i<3 ; i++)
print(i)
in swift:
for i in 1 ..< 3 {
print(i)
}
for i in 1 ... 3 {}
?