2023-10-02 01:41:38 +00:00
|
|
|
# Match
|
|
|
|
|
2023-12-17 01:33:55 +00:00
|
|
|
## Syntax
|
|
|
|
|
|
|
|
Braces are **required**.
|
2023-10-02 01:41:38 +00:00
|
|
|
|
|
|
|
```thp
|
2024-02-20 10:17:21 +00:00
|
|
|
val user_id = POST::get("user_id")
|
2023-10-02 01:41:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
match user_id
|
2023-12-17 01:33:55 +00:00
|
|
|
| Some(id) { print("user_id exists: {id}") }
|
2023-10-02 01:41:38 +00:00
|
|
|
| None { print("user_id doesn't exist") }
|
|
|
|
|
|
|
|
match user_id
|
|
|
|
| Some(id)
|
|
|
|
{
|
|
|
|
print("user_id exists: {id}")
|
|
|
|
}
|
|
|
|
| None
|
|
|
|
{
|
|
|
|
print("user_id doesn't exist")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
match user_id
|
|
|
|
| Some(id) if id > 0
|
|
|
|
{
|
|
|
|
print("user_id exists: {id}")
|
|
|
|
}
|
|
|
|
| _
|
|
|
|
{
|
|
|
|
print("user_id has other values ")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|