Skip to content

Instantly share code, notes, and snippets.

@Chandler
Created April 17, 2014 22:07
Show Gist options
  • Save Chandler/11014298 to your computer and use it in GitHub Desktop.
Save Chandler/11014298 to your computer and use it in GitHub Desktop.
type PrintSomething = (String) => String
val printer1: PrintSomething = (s: String) => {
print("\nI love " + s)
s
}
val printer2: PrintSomething = (s: String) => {
print("\nI hate " + s)
s
}
val multiPrinter = printer1.compose(printer2)
printer1("cats")
// I love cats
printer2("cats")
// I hate cats
multiPrinter("cats")
// I love cats
// I hate cats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment