fn main() {
// While
println!("/****** Laço While ******/");
let mut x = 200;
while x >= 10{
x = x / 2;
println!("X: {}", x);
}
println!("X Final: {}", x);
println!();
// For
println!("/****** Laço For ******/");
for y in 1..=5 {
println!("Y: {}", y);
}
println!();
for elem in [1, 2, 3, 4, 5] {
println!("Elemento: {}", elem);
}
println!();
// Loop
println!("/****** Laço Loop ******/");
let mut i = 0;
loop {
i += 1;
if i > 5 {
println!("PAROU");
break;
} else if i % 2 == 0 {
continue
}
println!("I: {i}");
}
}
Well, for a tutorial, this is a bit basic and lacks some informative explanations. Also, you may want to use English in your comments instead of Portuguese to make it understandable for a broader audience.
2 Likes