mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: fix interfaces example
This commit is contained in:
parent
ff216e7d50
commit
b92a3544f5
@ -885,14 +885,14 @@ interface Speaker {
|
||||
speak() string
|
||||
}
|
||||
|
||||
fn perform(s Speaker) {
|
||||
println(s.speak())
|
||||
fn perform(s Speaker) string {
|
||||
return s.speak()
|
||||
}
|
||||
|
||||
dog := Dog{}
|
||||
cat := Cat{}
|
||||
perform(dog) // "woof"
|
||||
perform(cat) // "meow"
|
||||
println(perform(dog)) // "woof"
|
||||
println(perform(cat)) // "meow"
|
||||
```
|
||||
|
||||
A type implements an interface by implementing its methods.
|
||||
|
Loading…
Reference in New Issue
Block a user