2021-07-08 02:58:36 +07:00
|
|
|
// functions5.rs
|
|
|
|
// Make me compile! Execute `rustlings hint functions5` for hints :)
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let answer = square(3);
|
|
|
|
println!("The answer is {}", answer);
|
|
|
|
}
|
|
|
|
|
2021-07-08 03:02:31 +07:00
|
|
|
// without ; the expression is a return statement
|
|
|
|
// it can be either both num * num or
|
|
|
|
// return num * num;
|
|
|
|
// but it cannot be
|
|
|
|
// return num * num OR num * num;
|
|
|
|
|
2021-07-08 02:58:36 +07:00
|
|
|
fn square(num: i32) -> i32 {
|
2021-07-08 03:02:31 +07:00
|
|
|
num * num
|
2021-07-08 02:58:36 +07:00
|
|
|
}
|