diff --git a/loops/src/main.rs b/loops/src/main.rs index 38fd301..b44e6b7 100644 --- a/loops/src/main.rs +++ b/loops/src/main.rs @@ -1,10 +1,7 @@ fn main() { let a = [10, 20, 30, 40, 50]; - let mut index = 0; - while index < 5 { - println!("the value is: {}", a[index]); - - index += 1; + for element in a { + println!("the value is: {element}"); } }