I am trying to use Swift 3 for-loops, but I have been unsuccessful. Here is what I have:
for assumedPayRate: Double in (0.25..<=billRate) where assumedPayRate += 0.25 {
On the ..<=
it gives me the error:
Use of unresolved operator '..<='
Here is the original Swift 2 version:
for var assumedPayRate:Double = 0.25; assumedPayRate <= billRate; assumedPayRate += 0.25 {
How can I fix this error?
You can use an
advanced operator
to do the job, but you need to write it your own. The official documentation may help.Swift has two range operators -
...
and..<
.The
...
operator corresponds towhile
..<
corresponds toin pseudocode.
You can use
...
operator for ¼ step (i.e.0.25
):There is no ..<=, you need to convert your statement to while
The operator
..<=
doesn't exist in Swift and your syntax is invalid. Usestride
instead: