wiki/dev/lang/rust/match.md

22 lines
299 B
Markdown
Raw Normal View History

2023-11-19 22:02:22 +03:00
# 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,
};
```