Skip to content

Commit be2bb2d

Browse files
authored
Speaker notes for Method example (#203)
* Speaker notes for Method example * Update example.md
1 parent 94ed176 commit be2bb2d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/methods/example.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ fn main() {
3939
race.finish();
4040
}
4141
```
42+
43+
<details>
44+
45+
Key Points:
46+
* All four methods here use a different method receiver.
47+
* You can point out how that changes what the function can do with the variable values and if/how it can be used again in `main`.
48+
* You can showcase the error that appears when trying to call `finish` twice.
49+
* Note, that although the method receivers are different, the non-static functions are called the same way in the main body. Rust enables automatic referencing and dereferencing when calling methods. Rust automatically adds in the `&`, `*`, `muts` so that that object matches the method signature.
50+
* You might point out that `print_laps` is using a vector that is iterated over. We describe vectors in more detail in the afternoon.
51+
52+
</details>

0 commit comments

Comments
 (0)