It seems that Swift allows, in Xcode Beta, floating point number in the range operator however the results are not desirable.
for i in 0..109.88 {
i
sin(Double(i))
}
This causes it to hang or run for a very long time. Perhaps this is just an oversight in this release and it should only allow integers? Does it even make sense for it to allow floats?
(UPDATE: this is the very old behavior of Swift 1.0 Beta probably could be archived).
This looks guaranteed to hang. Running this:
for i in 0..1.5 {
println(i)
}
Shows that i is incremented by 1.0 each iteration to infinity. It might be waiting for i == {upper limit} to break the loop, which never happens.
In the released version, this is resolved.
Joseph A Mark's answer indicated that a real number is used to increment the values. on testing the range 1.1...5.1, Swift indicated that the real range didn't have an automatic generator, so it couldn't be done.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With