File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -40,5 +40,8 @@ fn square(num: i32) -> i32 {
40
40
41
41
// This is a really common error that can be fixed by removing one character.
42
42
// It happens because Rust distinguishes between expressions and statements: expressions return
43
- // a value and statements don't. We want to return a value from the `square` function, but it
44
- // isn't returning one right now...
43
+ // a value based on its operand, and statements simply return a () type which behaves just like `void` in C/C++ language.
44
+ // We want to return a value of `i32` type from the `square` function, but it is returning a `()` type...
45
+ // They are not the same. There are two solusions:
46
+ // 1. Add a `return` ahead of `num * num;`
47
+ // 2. remove `;`, make it to be `num * num`
You can’t perform that action at this time.
0 commit comments