mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
docs: update section about Enum using reserved keywords (#22944)
This commit is contained in:
parent
660f73395e
commit
393e4ea8b2
1 changed files with 3 additions and 4 deletions
|
@ -3440,18 +3440,17 @@ The enum type can be any integer type, but can be omitted, if it is `int`: `enum
|
||||||
Enum match must be exhaustive or have an `else` branch.
|
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.
|
This ensures that if a new enum field is added, it's handled everywhere in the code.
|
||||||
|
|
||||||
Enum fields cannot re-use reserved keywords. However, reserved keywords may be escaped
|
Enum fields can re-use reserved keywords:
|
||||||
with an @.
|
|
||||||
|
|
||||||
```v
|
```v
|
||||||
enum Color {
|
enum Color {
|
||||||
@none
|
none
|
||||||
red
|
red
|
||||||
green
|
green
|
||||||
blue
|
blue
|
||||||
}
|
}
|
||||||
|
|
||||||
color := Color.@none
|
color := Color.none
|
||||||
println(color)
|
println(color)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue