doc: document that struct fields can now use keywords as their names (#23564)

This commit is contained in:
Mike Ward 2025-01-24 04:11:40 -06:00 committed by GitHub
parent a44ff7813a
commit b0d2eeea5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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