package main
import "fmt"
type person struct {
first string
last string
}
type secretAgent struct {
person
ltk bool
}
//func (r receiver) identifier(parameters) (return(s)){...}
func (s secretAgent) speak() {
fmt.Println("I am", s.first, s.last)
}
func main() {
sa1 := secretAgent{
person: person{
first: "James",
last: "Bond",
},
ltk: true,
}
fmt.Println(sa1)
sa1.speak()
}
I am aware that the receiver spot makes it so only those of that type have access to this function… in this case those with the type of secretAgent
, but what does the s
next to it mean? is that the equivalent to a parameter inside of the func speak()
…