Created
November 25, 2014 02:03
-
-
Save kinwahlai/5f209b2a33a674d3e007 to your computer and use it in GitHub Desktop.
Groovy chaining
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
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