Documentation ¶
Overview ¶
Declare an interface named speaker with a method named sayHello. Declare a struct named English that represents a person who speaks english and declare a struct named Chinese for someone who speaks chinese. Implement the speaker interface for each struct using a value receiver and these literal strings "Hello World" and "你好世界". Declare a variable of type speaker and assign the _address of_ a value of type English and call the method. Do it again for a value of type Chinese.
Add a new function named sayHello that accepts a value of type speaker. Implement that function to call the sayHello method on the interface value. Then create new values of each type and use the function.
Click to show internal directories.
Click to hide internal directories.