pub fn functions_are_expressions() -> i32
Expand description

Functions are expressions, and so are their contents.

This is the foundation of the other items in this modules, because it is in using functions as expressions that we’ll be able to demonstrate clearly that if blocks and match blocks are also expressions.

Note that we can see several things going on in the body of this function:

  1. The items within the function are expressions.
  2. The function returns the value of the final expression in the function body. But a better way to think about it is to see the function as having that value itself, because…
  3. The function itself is an expression, which is evaluated to have the value of that final expression!