1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

docs: structs: more info on default field values

This commit is contained in:
Alexander Medvednikov 2020-05-17 16:01:02 +02:00 committed by GitHub
parent 627400723c
commit 2de127f045
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -656,11 +656,15 @@ button.widget.set_pos(x,y)
```v
struct Foo {
n int // n is 0 by default
s string // s is '' by default
a []int // a is `[]int{}` by default
pos int = -1 // custom default value
}
```
All struct fields are zeroed by default during the creation of the struct. But it's also possible to define custom default values.
All struct fields are zeroed by default during the creation of the struct. Array and map fields are allocated.
It's also possible to define custom default values.
## Access modifiers