E4138#
Range operators only support builtin integer types, they cannot be used on this type.
Erroneous example#
For example, you cannot use Float
nor Double
with range operators.
fn main {
for f in 0.0..<1.0 {
}
}
Suggestion#
Use integer types for the range operators, and genearte floats from these integers instead:
fn main {
for i in 0..<10 {
println(i.to_float())
}
}
You can also use until
to construct a range of numbers:
fn main {
let range : Iter[Double] = (0.0).until(10.0)
for i in range {
println(i)
}
}