summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorCarol (Nichols || Goulding) <carol.nichols@gmail.com>2015-09-18 20:28:27 -0400
committerCarol (Nichols || Goulding) <carol.nichols@gmail.com>2015-09-18 20:28:27 -0400
commit36a75c733e4bf3f5ae5f375adb2b290c09494481 (patch)
tree9f859436d6a0ef5876585b67bb25b7944bfcdf60 /functions
parent9336aed2b94264cd00aab60defcaae462efb8bc0 (diff)
Just remembered another function one I wanted to do
Diffstat (limited to 'functions')
-rw-r--r--functions/functions5.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/functions/functions5.rs b/functions/functions5.rs
new file mode 100644
index 0000000..a8d7cef
--- /dev/null
+++ b/functions/functions5.rs
@@ -0,0 +1,43 @@
+// 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...