The code below will never print 3, and should not be an if/else. I think it's confusing to new learners to include code that does not do what it suggests. This code prints "number is smaller than 5" for everything < 5 and for anything >=5 it prints "number greater than or equal to 3, but smaller than 5" for any other value.
let number = 3;
if number < 5 {
println!("`number` is smaller than 5");
} else if number >= 3 {
println!("`number` is greater than or equal to 3, but smaller than 5");
} else {
println!("`number` is smaller than 3");
}
This should be changed to an example that actually requires the use of if else and does what it is supposed to do.
The code below will never print 3, and should not be an if/else. I think it's confusing to new learners to include code that does not do what it suggests. This code prints "number is smaller than 5" for everything < 5 and for anything >=5 it prints "number greater than or equal to 3, but smaller than 5" for any other value.
This should be changed to an example that actually requires the use of if else and does what it is supposed to do.