summaryrefslogtreecommitdiff
path: root/old_curriculum/functions/functions5.rs
blob: f8fac5d2c72c05648bc2e9fc333112996f181efc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// functions5.rs
// Make me compile! Scroll down for hints :)

fn main() {
    let answer = square(3);
    println!("The answer is {}", answer);
}

fn square(num: i32) -> i32 {
    num * num;
}





























// This is a really common error that can be fixed by removing one character.
// It happens because Rust distinguishes between expressions and statements: expressions return
// a value and statements don't. We want to return a value from the `square` function, but it
// isn't returning one right now...