mirror of
https://github.com/vlang/v.git
synced 2025-09-09 23:39:39 -04:00
docs: update section about Enum using reserved keywords (#22944)
This commit is contained in:
parent
660f73395e
commit
393e4ea8b2
@ -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…
x
Reference in New Issue
Block a user