File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
courses/rust_essentials/040_control_flow_basics Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ Using "match" as a Statement
2020 0 => {
2121 println!("Grumble");
2222 println!("Must protest");
23- } // Comma is optional, unidiomatic
23+ } // Comma is optional here, usually omitted
2424 1 => {
2525 println!("Tail wag engaged")
26- } // Block for single expression is optional, unidiomatic
27- 2 => println!("Maximum happiness "),
28- _ => println!("Suspicion"), // Comma is optional , idiomatic
26+ } // Block is valid but unnecessary for one line
27+ 2 => println!("Happiness! "), // Comma is REQUIRED here
28+ _ => println!("Suspicion"), // Trailing comma is allowed , idiomatic
2929 }
3030
3131--------------------------------
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ What is a function?
77---------------------
88
99- Primary way to organize code into reusable blocks
10- - Take inputs, process them, and (often) return a value
10+ - Take inputs, process them, and return a result (even if empty)
1111- Declared using the :rust: `fn ` keyword
1212 - Must be immediately followed by the body enclosed in :rust: `{ } `
1313- Typically in **snake_case ** (e.g., :rust: `calculate_area `)
You can’t perform that action at this time.
0 commit comments