Skip to content

Instantly share code, notes, and snippets.

@notyy
Created March 18, 2012 17:22
Show Gist options
  • Save notyy/2077987 to your computer and use it in GitHub Desktop.
Save notyy/2077987 to your computer and use it in GitHub Desktop.
andThen
def step1 : Int => Int = _ + 2
def step2: Int => String = _.toString
def step3: String => Unit = (s) => println(s + " good")
val all = step1 andThen step2 andThen step3
----------------------------------------
scala> :l AndThen.scala
Loading AndThen.scala...
step1: Int => Int
step2: Int => String
step3: String => Unit
all: Int => Unit = <function1>
scala> all(2)
4 good
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment