docs: update section about Enum using reserved keywords (#22944)

This commit is contained in:
Felipe Pena 2024-11-23 09:17:45 -03:00 committed by GitHub
parent 660f73395e
commit 393e4ea8b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)
``` ```