MCPcopy Create free account
hub / github.com/mmcgrana/gobyexample / area

Method area

examples/interfaces/interfaces.go:29–31  ·  view source on GitHub ↗

To implement an interface in Go, we just need to implement all the methods in the interface. Here we implement `geometry` on `rect`s.

()

Source from the content-addressed store, hash-verified

27// implement all the methods in the interface. Here we
28// implement `geometry` on `rect`s.
29func (r rect) area() float64 {
30 return r.width * r.height
31}
32func (r rect) perim() float64 {
33 return 2*r.width + 2*r.height
34}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected