Created
June 8, 2015 06:54
-
-
Save bolilla/f681808cd18e4c16966f to your computer and use it in GitHub Desktop.
GoPadawan CompoInterfaces Interfaz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type motor struct { | |
ruido string | |
} | |
func (n motor) hacerRuido() string { | |
return fmt.Sprintf("Este motor hace: %s", n.ruido) | |
} | |
type cosaRuidosa interface { | |
hacerRuido() string | |
} | |
func main() { | |
var ruidoso cosaRuidosa | |
ruidoso = motor{"¡Brrroum!"} | |
fmt.Println(ruidoso.hacerRuido()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment