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

doc: fix Interfaces example (#6499)

This commit is contained in:
Andrei Kurhan
2020-09-30 08:42:23 +03:00
committed by GitHub
parent 4cd5153b32
commit 763ddf78f3

View File

@@ -1440,8 +1440,12 @@ particularly useful for initializing a C library.
### Interfaces
```v
struct Dog {}
struct Cat {}
struct Dog {
breed string
}
struct Cat {
}
fn (d Dog) speak() string {
return 'woof'
@@ -1465,8 +1469,9 @@ fn perform(s Speaker) string {
return s.speak()
}
dog := Dog{}
dog := Dog{'Leonberger'}
cat := Cat{}
println(perform(dog)) // "woof"
println(perform(cat)) // "meow"
```