From b0d2eeea5dfb78d5784875b5f45b6998a9c4de6b Mon Sep 17 00:00:00 2001 From: Mike Ward Date: Fri, 24 Jan 2025 04:11:40 -0600 Subject: [PATCH] doc: document that struct fields can now use keywords as their names (#23564) --- doc/docs.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/doc/docs.md b/doc/docs.md index 4593d2f5a4..fddbf987bd 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -2408,6 +2408,21 @@ p = Point{10, 20} assert p.x == 10 ``` +Struct fields can re-use reserved keywords: + +```v +struct Employee { + type string + name string +} + +employee := Employee{ + type: 'FTE' + name: 'John Doe' +} +println(employee.type) +``` + ### Heap structs Structs are allocated on the stack. To allocate a struct on the heap