Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/control-flow/match-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ that sense, it works like a series of `if let` expressions:

```rust,editable
fn main() {
match std::env::args().next().as_deref() {
Some("cat") => println!("Will do cat things"),
Some("ls") => println!("Will ls some files"),
Some("mv") => println!("Let's move some files"),
Some("rm") => println!("Uh, dangerous!"),
None => println!("Hmm, no program name?"),
_ => println!("Unknown program name!"),
let args: Vec<String> = std::env::args().collect();

for s in &args[1..] {
match &s[..] {
"cat" => println!("Will do cat things"),
"ls" => println!("Will ls some files"),
"mv" => println!("Let's move some files"),
"rm" => println!("Uh, dangerous!"),
_ => println!("Unknown program name!"),
}
}
}
```
Expand Down