method set (I) ⊆ method set (T)
Implicit satisfaction
Slide 38
Slide 38 text
Method sets
Slide 39
Slide 39 text
The method set of any other type T consists of all
methods declared with receiver type T.
The method set of a pointer type *T is the set of all
methods declared with receiver *T or T.
The method set of an interface type is its interface
Slide 40
Slide 40 text
The method set of any other type T consists of all
methods declared with receiver type T.
The method set of a pointer type *T is the set of all
methods declared with receiver *T or T.
The method set of an interface type is its interface
Slide 41
Slide 41 text
The method set of any other type T consists of all
methods declared with receiver type T.
The method set of a pointer type *T is the set of all
methods declared with receiver *T or T.
The method set of an interface type is its interface
Slide 42
Slide 42 text
type Person struct {
Name string
Age int
}
func (p *Person) String() string {
return fmt.Sprintf("%s is %d", p.Name, p.Age)
}
func main() {
p := &Person{"Hillary", 66}
fmt.Println(p)
}
Slide 43
Slide 43 text
type Person struct {
Name string
Age int
}
func (p *Person) String() string {
return fmt.Sprintf("%s is %d", p.Name, p.Age)
}
func main() {
p := &Person{"Hillary", 66}
fmt.Println(p)
}
Slide 44
Slide 44 text
Hillary is 66 years old
Slide 45
Slide 45 text
type Person struct {
Name string
Age int
}
func (p Person) String() string {
return fmt.Sprintf("%s is %d", p.Name, p.Age)
}
func main() {
p := &Person{"Hillary", 66}
fmt.Println(p)
}
Slide 46
Slide 46 text
Hillary is 66 years old
Slide 47
Slide 47 text
The method set of any other type T consists of all
methods declared with receiver type T.
The method set of a pointer type *T is the set of all
methods declared with receiver *T or T.
The method set of an interface type is its interface
Slide 48
Slide 48 text
type Person struct {
Name string
Age int
}
func (p Person) String() string {
return fmt.Sprintf("%s is %d", p.Name, p.Age)
}
func main() {
p := Person{"Hillary", 66}
fmt.Println(p)
}
Slide 49
Slide 49 text
Hillary is 66 years old
Slide 50
Slide 50 text
type Person struct {
Name string
Age int
}
func (p *Person) String() string {
return fmt.Sprintf("%s is %d", p.Name, p.Age)
}
func main() {
p := Person{"Hillary", 66}
fmt.Println(p)
}
Slide 51
Slide 51 text
{Hillary 66}
Slide 52
Slide 52 text
func (T) Foo() func (*T) Foo()
Slide 53
Slide 53 text
func (T) Foo() func (*T) Foo()
T → T *T → *T
Slide 54
Slide 54 text
func (T) Foo() func (*T) Foo()
T → T *T → *T
*T → T
Slide 55
Slide 55 text
func (T) Foo() func (*T) Foo()
T → T *T → *T
*T → T T → *T
Slide 56
Slide 56 text
&42
Slide 57
Slide 57 text
func (T) Foo() func (*T) Foo()
T → T *T → *T
*T → T T ↛ *T
- Eyjafjallajökull By Boaworm (Own work) CC-BY-3.0 via Wikimedia
Commons
- Yoda picture “Save you it can.” by JD Hancock is licensed under a
Creative Commons Attribution 3.0
- Chinese letters by Michael Coghlan is licensed under a Creative
Commons Attribution 3.0
Attributions