22 lines
299 B
Markdown
22 lines
299 B
Markdown
# Match (switch).
|
|
|
|
# Example.
|
|
|
|
Parentheses around match are optional, like `match number {`.
|
|
|
|
```rust
|
|
let number = 10;
|
|
|
|
match (number) {
|
|
1 => foo(),
|
|
2 | 3 | 4 => foo(),
|
|
13..19 => foo(),
|
|
_ => default()
|
|
}
|
|
|
|
let expr = match (number > 10) {
|
|
true => 1,
|
|
false => 0,
|
|
};
|
|
```
|