more clear explanation for interface (#2779)

more clear explanation why interface is consider defined without specifically declaring it (like in other languages `pair implement Stringer`)
This commit is contained in:
gondo 2017-07-02 20:38:55 +08:00 committed by ven
parent e78e41ce30
commit 801484a23b

View File

@ -295,7 +295,7 @@ type pair struct {
x, y int
}
// Define a method on type pair. Pair now implements Stringer.
// Define a method on type pair. Pair now implements Stringer because Pair has defined all the methods in the interface.
func (p pair) String() string { // p is called the "receiver"
// Sprintf is another public function in package fmt.
// Dot syntax references fields of p.