1
0
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:
Delyan Angelov
2022-10-29 06:32:20 +03:00
committed by GitHub
parent 4564a47fbc
commit 02c3af2432
18 changed files with 567 additions and 54 deletions

View File

@@ -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.