mirror of
https://github.com/vlang/v.git
synced 2025-09-09 07:15:50 -04:00
docs: add undocumented behavior (#19177)
This commit is contained in:
parent
50ed7316eb
commit
2ce7109b30
16
doc/docs.md
16
doc/docs.md
@ -3150,6 +3150,17 @@ pub fn say_hi() {
|
|||||||
println('hello from mymodule!')
|
println('hello from mymodule!')
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
All items inside a module can be used between the files of a module regardless of whether or
|
||||||
|
not they are prefaced with the `pub` keyword.
|
||||||
|
```v failcompile
|
||||||
|
// myfile2.v
|
||||||
|
module mymodule
|
||||||
|
|
||||||
|
pub fn say_hi_and_bye() {
|
||||||
|
say_hi() // from myfile.v
|
||||||
|
println('goodbye from mymodule')
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
You can now use `mymodule` in your code:
|
You can now use `mymodule` in your code:
|
||||||
|
|
||||||
@ -3158,6 +3169,7 @@ import mymodule
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
mymodule.say_hi()
|
mymodule.say_hi()
|
||||||
|
mymodule.say_hi_and_bye()
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -3453,7 +3465,9 @@ fn fn1(s Foo) {
|
|||||||
|
|
||||||
#### Casting an interface
|
#### Casting an interface
|
||||||
|
|
||||||
We can test the underlying type of an interface using dynamic cast operators:
|
We can test the underlying type of an interface using dynamic cast operators.
|
||||||
|
> **Note**
|
||||||
|
> Dynamic cast converts variable `s` into a pointer inside the `if` statemnts in this example:
|
||||||
|
|
||||||
```v oksyntax
|
```v oksyntax
|
||||||
// interface-example.3 (continued from interface-example.1)
|
// interface-example.3 (continued from interface-example.1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user