mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
docs: add field shadowing comment (#20521)
This commit is contained in:
parent
acf75c71da
commit
33598ca005
1 changed files with 18 additions and 1 deletions
19
doc/docs.md
19
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
|
## V Types
|
||||||
|
|
||||||
### Primitive types
|
### Primitive types
|
||||||
|
@ -7308,4 +7325,4 @@ Assignment Operators
|
||||||
+= -= *= /= %=
|
+= -= *= /= %=
|
||||||
&= |= ^=
|
&= |= ^=
|
||||||
>>= <<= >>>=
|
>>= <<= >>>=
|
||||||
```
|
```
|
Loading…
Add table
Add a link
Reference in a new issue