docs: fix interfaces example

pull/2940/head
ibalbaert 2019-11-30 09:18:06 +01:00 committed by Alexander Medvednikov
parent ff216e7d50
commit b92a3544f5
1 changed files with 4 additions and 4 deletions

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.