From 5f77f62dd9c14d8a8851985a9371b4a6310f2b5f Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 16 Oct 2024 17:27:33 +0200 Subject: [PATCH] Create an array iterator --- loops/src/main.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/loops/src/main.rs b/loops/src/main.rs index ca070c7..38fd301 100644 --- a/loops/src/main.rs +++ b/loops/src/main.rs @@ -1,11 +1,10 @@ fn main() { - let mut number = 3; + let a = [10, 20, 30, 40, 50]; + let mut index = 0; - while number != 0 { - println!("{number}!"); + while index < 5 { + println!("the value is: {}", a[index]); - number -= 1; + index += 1; } - - println!("LIFTOFF!!!"); }