DEV Community

Discussion on: Introduction to Go for PHP Developers

Collapse
 
ladydascalie profile image
Benjamin Cable • Edited
func (c Cup) nameAndColor() string {
  return c.name + ": " + c.color
}

This would be much better served by satisfying the Stringer interface:

func (c Cup) String() string {
     return c.name + ": " + c.color
}

I would recommend following the tour here: tour.golang.org/methods/17
To see in greater detail why this is a more useful way to do this.

Collapse
 
restoreddev profile image
Andrew Davis

Thanks for pointing that out. I just wrote the method as an example, nothing more.