Skip to content

Instantly share code, notes, and snippets.

@bolilla
Created May 30, 2015 11:37
Show Gist options
  • Save bolilla/11a3c2a4288287aac289 to your computer and use it in GitHub Desktop.
Save bolilla/11a3c2a4288287aac289 to your computer and use it in GitHub Desktop.
GoPadawan Composicion como C
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