Skip to content

Instantly share code, notes, and snippets.

@kinwahlai
Created November 25, 2014 02:03
Show Gist options
  • Save kinwahlai/5f209b2a33a674d3e007 to your computer and use it in GitHub Desktop.
Save kinwahlai/5f209b2a33a674d3e007 to your computer and use it in GitHub Desktop.
Groovy chaining
class ChainExample {
static String callClosure(){
def aClosure = { ->
{ ->
"this is second closure"
}
}
aClosure()()
}
static int callAddition(){
def addLogic = { x, y ->
x + y
}
def addition = { x ->
{ y ->
addLogic(x,y)
}
}
println addition(1)(1)
def increaseBy2 = addition(2)
println increaseBy2(3)
addLogic.curry(2)(3)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment