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}");
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Statements

A

are instructions that perform some action and do not return a value.

Example:
~~~
let x = 3;
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Expressions

A

Expressions evaluate to a resultant value. Let’s look at some examples.

Example:
~~~
{
let x = 3;
x + 1
}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly