mirror of
https://github.com/vlang/v.git
synced 2025-09-10 07:47:20 -04:00
docs: add field shadowing comment (#20521)
This commit is contained in:
parent
acf75c71da
commit
33598ca005
17
doc/docs.md
17
doc/docs.md
@ -480,7 +480,24 @@ fn main() {
|
||||
}
|
||||
}
|
||||
```
|
||||
While variable shadowing is not allowed, field shadowing is allowed.
|
||||
```v
|
||||
pub struct Dimension {
|
||||
width int = -1
|
||||
height int = -1
|
||||
}
|
||||
|
||||
pub struct Test {
|
||||
Dimension
|
||||
width int = 100
|
||||
// height int
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test := Test{}
|
||||
println('${test.width} ${test.height} ${test.Dimension.width}') // 100 -1 -1
|
||||
}
|
||||
```
|
||||
## V Types
|
||||
|
||||
### Primitive types
|
||||
|
Loading…
x
Reference in New Issue
Block a user