Functions Review

This chapter covered:

  • Functions with no parameters
  • Functions with parameters
  • Using parameters
  • Functions with return values
  • Binding return values

Here's a review the combines everything. It outputs

sum is 12

SOURCE CODE

fn main() {
  let sum = do_addition(5, 7);
  println!("sum is {}", sum);
}

fn do_addition(alfa: i32, bravo: i32) -> i32 {
  let response = alfa + bravo;
  response
}

CODE RUNNER