Created
June 23, 2014 18:08
-
-
Save johnvilsack/ca090f90e8852477d080 to your computer and use it in GitHub Desktop.
How Interfaces Work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
type ZipCoder interface { | |
fullName() string | |
} | |
type CustRecord struct { | |
FirstName, LastName string | |
} | |
func (c CustRecord) fullName() string { | |
return c.FirstName + " :: " + c.LastName | |
} | |
func main() { | |
CustOne := CustRecord{"John", "Vilsack"} | |
CustTwo := CustRecord{"Rachel", "Vilsack"} | |
fmt.Printf("%v", ZipCoder.fullName(CustOne)) | |
fmt.Printf("%v", ZipCoder.fullName(CustTwo)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment