Last active
December 21, 2015 09:39
-
-
Save simonjefford/6286607 to your computer and use it in GitHub Desktop.
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" | |
"strings" | |
) | |
type Name string | |
func (n Name) FirstName() string { | |
return strings.Split(string(n), " ")[0] | |
} | |
func (n Name) Surname() string { | |
return strings.Split(string(n), " ")[1] | |
} | |
func PrintNameDetails(n Name) { | |
fmt.Println("First:", n.FirstName(), " Last:", n.Surname()) | |
} | |
func main() { | |
var simon = Name("Simon Jefford") | |
PrintNameDetails(simon) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment