mirror of
https://github.com/andwati/rustlings.git
synced 2026-11-16 17:15:13 +00:00
functions
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
fn square(num: i32) -> i32 {
|
||||
// Removed the semicolon `;` at the end of the line below to implicitly return the result.
|
||||
num * num
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// DON'T EDIT THIS SOLUTION FILE!
|
||||
// It will be automatically filled after you finish the exercise.
|
||||
let answer = square(3);
|
||||
println!("The square of 3 is {answer}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user