Chapter 2 · Practice 2 of 4
Type the examples and change them, do not just read them
Why it matters
Reading code feels like learning, but it mostly builds a sense of familiarity. Typing examples, running them and then changing them builds real understanding.
For each example in a tutorial:
- Type it rather than copy it. You notice details you would skim.
- Run it and check the output matches what you expected.
- Break it on purpose: remove a line, change a type, pass bad input.
- Read the error. You will meet that error again in real work.
The Rust Book is a good model: it mixes concept chapters with project chapters, such as a guessing game, a command line tool and a multithreaded web server, so you build as you go.
Do
- Run every example and then modify it
- Break examples deliberately to see the errors
Avoid
- Reading a whole tutorial without opening an editor