Update the code to use a for
loop
This commit is contained in:
parent
5f77f62dd9
commit
808b8f58b0
1 changed files with 2 additions and 5 deletions
|
@ -1,10 +1,7 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = [10, 20, 30, 40, 50];
|
let a = [10, 20, 30, 40, 50];
|
||||||
let mut index = 0;
|
|
||||||
|
|
||||||
while index < 5 {
|
for element in a {
|
||||||
println!("the value is: {}", a[index]);
|
println!("the value is: {element}");
|
||||||
|
|
||||||
index += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue