Created
June 16, 2015 11:52
-
-
Save imjacobclark/d95863e473baa684a07c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Salutation struct { | |
name string | |
greeting string | |
} | |
type Printer func(string) () | |
func Greet(salutation Salutation, do Printer) { | |
message, alternative := CreateMessage(salutation.name, salutation.greeting, "yo", "hey"); | |
do(message) | |
do(alternative) | |
} | |
func CreateMessage(name string, greeting ...string) (message string, alternate string) { | |
fmt.Println(len(greeting)) | |
message = greeting[1] + " " + name | |
alternate = "Hey " + name | |
return | |
} | |
func Print(s string) { | |
fmt.Print(s) | |
} | |
func PrintLine(s string) { | |
fmt.Println(s) | |
} | |
func CreatePrintFunction(custom string) Printer { | |
return func(s string){ | |
fmt.Println(s + custom) | |
} | |
} | |
func main() { | |
var s = Salutation{"Jacob", "Hello"} | |
Greet(s, CreatePrintFunction("!!!")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment