From b8d93df55e3b44d2b295eb41c4397bac06f4812f Mon Sep 17 00:00:00 2001 From: William Gooch Date: Fri, 29 Jan 2021 14:09:24 -0500 Subject: [PATCH] docs: add axample of escaping a v keyword in enums (#8425) --- doc/docs.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/docs.md b/doc/docs.md index bcbba4be07..5ddca07769 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -1928,6 +1928,21 @@ match 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. +Enum fields cannot re-use reserved keywords. However, reserved keywords may be escaped +with an @. + +```v +enum Color { + @none + red + green + blue +} + +color := Color.@none +println(color) +``` + ### Sum types A sum type instance can hold a value of several different types. Use the `type`