Curriculum Foundations Control flow
Control flow
Rust's if and loops look familiar, but they are expressions more often than TypeScript developers expect. This theme covers if, else if, loop, while, for, ranges, break, continue, and match only as a first glimpse. Planned exercises: 1. choose Rust if syntax without parentheses. 2. choose an if expression value. 3. recognise for n in 0..5. 4. fill a range. 5. fill break with a value from loop. 6. write a while condition. 7. write a for loop over a range. 8. translate TS branching code. 9. write a small counter that prints selected values.
Exercises
9 ready
01
pick one
Pick the idiomatic Rust if statement. Unlike TypeScript, Rust
02
pick one
In Rust, if is an EXPRESSION — it produces a value you can bind
03
pick one
Pick the idiomatic Rust loop that prints 0 through 4. Rust's
04
fill blanks
Fill the Rust range operator that iterates start UP TO BUT NOT
05
fill blanks
Fill the keyword that exits a loop AND returns a value from it.
06
type one line
Write the Rust while line that loops as long as n is greater
07
type one line
Write the Rust for line that iterates i over 1, 2, 3
08
write a program
Translate the TypeScript branching code. The program prints
09
write a program
Write a Rust program that iterates i from 1 through 5