-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctoins-Interfaces.go
64 lines (53 loc) · 1.03 KB
/
functoins-Interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package main
import "fmt"
type persona struct {
nombre string
apellido string
}
type agenteSecreto struct {
persona
lpm bool
}
// A method.
func (a agenteSecreto) presesentarse() {
fmt.Println("Hola, soy ", a.nombre, a.apellido, "EL agente secreto se presenta")
}
// A method.
func (p persona) presesentarse() {
fmt.Println("Hola soy", p.nombre, p.apellido, "la peronsa se presenta")
}
// A humano is a type that can present itself.
// @property presesentarse - This is the method signature.
type humano interface {
presesentarse()
}
// Bar takes a humano as an argument
func bar(h humano) {
fmt.Println("Fui pasado a la función bar", h)
}
func main() {
as1 := agenteSecreto{
persona: persona{
nombre: "Diego",
apellido: "Lopez",
},
lpm: true,
}
as2 := agenteSecreto{
persona: persona{
nombre: "Alberto",
apellido: "Murillo",
},
lpm: false,
}
/* p := persona{
nombre: "CAAL",
apellido: "Guzman",
} */
fmt.Println(as1)
as1.presesentarse()
as2.presesentarse()
bar(as1)
bar(as2)
//bar(p)
}