template1

command
v0.0.0-...-35bbffe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2015 License: Apache-2.0 Imports: 0 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL