mirror of
https://github.com/vlang/v.git
synced 2025-09-08 06:41:58 -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.
|
||||
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
|
||||
with an @.
|
||||
Enum fields can re-use reserved keywords:
|
||||
|
||||
```v
|
||||
enum Color {
|
||||
@none
|
||||
none
|
||||
red
|
||||
green
|
||||
blue
|
||||
}
|
||||
|
||||
color := Color.@none
|
||||
color := Color.none
|
||||
println(color)
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user