Re: the language feature: This is standard in ML-family/typed functional languages (OCaml, Haskell...), and lately has been being adopted by a lot of newer languages, including Rust and Swift.
fn main() {
for i in 1..102 {
match (i % 3 == 0, i % 5 == 0) {
(true, true) => println!("FizzBuzz"),
(true, false) => println!("Fizz"),
(false, true) => println!("Buzz"),
(false, false) => println!("{}", i)
}
}
}
Not only is it obviously correct, but if you somehow manage to forget a case the compiler will tell you. {
if A && B return println("FizzBuss");
if A && !B return println("Fizz");
if !A && B return println("Buzz");
if !A && !B return println("{}", i);
}