R4: Functions Flashcards
1
Q
Functions Syntax
A
fn main() { print_labeled_measurement(5, 'h'); } fn print_labeled_measurement(value: i32, unit_label: char) { println!("The measurement is: {value}{unit_label}"); }
2
Q
Statements
A
are instructions that perform some action and do not return a value.
Example:
~~~
let x = 3;
~~~
3
Q
Expressions
A
Expressions evaluate to a resultant value. Let’s look at some examples.
Example:
~~~
{
let x = 3;
x + 1
}
~~~