Created
June 8, 2015 06:55
-
-
Save bolilla/3fed4b0fe5ab038c8ddc to your computer and use it in GitHub Desktop.
GoPadawan CompoInterfaces Composicion
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 | |
} | |
type naveEspacial struct { | |
numLasers int | |
capcidadPasajeros int | |
motor | |
} | |
func main() { | |
var miMotor = motor{"¡Brrroum!"} | |
var miNave = naveEspacial{4, 2, miMotor} | |
fmt.Println(miNave.hacerRuido()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment