Declaring an interface is fairly simple:

Both types Witch and Unicorn implement the Healer interface, because both have a method called heal() that returns a string. It is in fact important that the signatures for each heal() method be exactly the same. If the Unicorn 's version of heal() returned a bool , for instance, it would not be the same method that is stated in the Healer interface (which returns a string ), and thus not implement the Healer interface.



Additionally, we can use type Healer as an argument to the sleep() function. This allows us to write sleep() only once, and have it apply to all Healers (healers gotta get their beauty sleep too).





Let's look at using the above types in main() :