Created
May 30, 2015 11:37
-
-
Save bolilla/11a3c2a4288287aac289 to your computer and use it in GitHub Desktop.
GoPadawan Composicion como C
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 empuñadura string | |
type filo string | |
type espada struct { | |
e empuñadura | |
f filo | |
} | |
type vaina string | |
type espadaEnvainada struct { | |
e espada | |
v vaina | |
} | |
func (ee espadaEnvainada) describe() string { | |
return fmt.Sprintf( | |
"Espada Envainada, con puño de '%s', filo de '%s' y vaina de '%s'", | |
ee.e.e, ee.e.f, ee.v) | |
} | |
func main() { | |
var miEspadaEnvainada = espadaEnvainada{ | |
espada{"Cuero trenzado", "Acero"}, "Cuero curtido", | |
} | |
fmt.Println(miEspadaEnvainada.describe()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment