With Variables
We can also use variables for the starting and ending numbers of the range. Instead of:
1..=5
We set start
and end
variables then
use them with:
start..=end
Here's the updated version that also outputs:
alfa is 1
alfa is 2
alfa is 3
alfa is 4
alfa is 5
SOURCE CODE
fn main() {
let start = 1;
let end = 5;
for alfa in start..=end {
println!("alfa is {alfa}");
}
}