mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: add support for enum Xyz as u64 { + tests (#16246)
This commit is contained in:
@@ -3237,7 +3237,7 @@ You can see the complete
|
||||
### Enums
|
||||
|
||||
```v
|
||||
enum Color {
|
||||
enum Color as u8 {
|
||||
red
|
||||
green
|
||||
blue
|
||||
@@ -3254,6 +3254,8 @@ match color {
|
||||
}
|
||||
```
|
||||
|
||||
The enum type can be any integer type, but can be ommited, if it is `int`: `enum Color {`.
|
||||
|
||||
Enum match must be exhaustive or have an `else` branch.
|
||||
This ensures that if a new enum field is added, it's handled everywhere in the code.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user