...

/

Functions Returning Booleans

Functions Returning Booleans

We'll cover the following...

Since bool is a type just like i32, we can return it from functions.

Press + to interact
fn temperature() -> i32 {
15 // feel free to change this!
}
fn is_hot() -> bool {
temperature() > 30
}
fn main() {
assert!(is_hot() == false);
println!("Success!");
}

Here, we have a temperature function that pretends to get the ...