1
0
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:
ibalbaert 2019-11-30 09:18:06 +01:00 committed by Alexander Medvednikov
parent ff216e7d50
commit b92a3544f5

View File

@ -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.